Gestionar Celdas con Cadena Html

Escenarios de uso posibles

Cuando necesite establecer datos con estilo para una celda específica, puede asignar una cadena html a la celda. Por supuesto, también puede obtener la cadena HTML de la celda. Aspose.Cells ofrece esta característica. Aspose.Cells proporciona las siguientes propiedades y métodos para ayudarlo a alcanzar sus objetivos.

Obtener y establecer cadena HTML usando Aspose.Cells

Este ejemplo muestra cómo:

  1. Crear un libro de trabajo y agregar algunos datos.
  2. Obtener la celda específica en la primera hoja de cálculo.
  3. Establecer cadena HTML en la celda.
  4. Obtener cadena HTML de la celda.
//Instantiating an Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the newly added worksheet
Worksheet ws = workbook.Worksheets[0];
Cells cells = ws.Cells;
//Setting the value to the cells
Cell cell = cells["A1"];
cell.PutValue("Fruit");
cell = cells["B1"];
cell.PutValue("Count");
cell = cells["C1"];
cell.PutValue("Price");
cell = cells["A2"];
cell.PutValue("Apple");
cell = cells["A3"];
cell.PutValue("Mango");
cell = cells["A4"];
cell.PutValue("Blackberry");
cell = cells["A5"];
cell.PutValue("Cherry");
Cell c3 = cells["C3"];
//set html string for C3 cell.
c3.HtmlString = "<b>test bold</b>";
Cell c4 = cells["C4"];
//set html string for C4 cell.
c4.HtmlString = "<i>test italic</i>";
//get the html string of specific cell.
Console.WriteLine(c3.HtmlString);
Console.WriteLine(c4.HtmlString);

Resultado generado por el código de ejemplo

La siguiente captura de pantalla muestra la salida del código de muestra anterior.

todo:image_alt_text