Posted By

nausherwan on 05/30/14


Tagged

html worksheet workbook Aspose asposecells


Versions (?)

Get or Set Html string as value of Cell in Worksheet using Aspose.Cells for .NET


 / Published in: C#
 

This sample application demonstrates the feature of Aspose.Cells for .NET API to Get and Set Html string from a Cell in an Excel file.

  1. //Instantiate the workbook object
  2. Workbook workbook = new Workbook();
  3.  
  4. //Get first worksheet of workbook
  5. Worksheet worksheet1 = workbook.Worksheets[0];
  6.  
  7. //Get Cells in a Worksheet
  8. Cells cells = worksheet1.Cells;
  9.  
  10. //Get the individual cell
  11. Aspose.Cells.Cell cell = cells["A1"];
  12.  
  13. //Set HTML string as Cell Text
  14. cell.HtmlString = ("<Font Style='FONT-FAMILY: Arial;FONT-SIZE: 10pt;COLOR: #000000;'>This is normal text - </Font><Font Style='FONT-WEIGHT: bold;FONT-FAMILY: Arial;FONT-SIZE: 10pt;COLOR: #000000;'>and this is bold text</Font><Font Style='FONT-FAMILY: Arial;FONT-SIZE: 10pt;COLOR: #000000;'>.</Font>");
  15.  
  16. //Save the workbook.
  17. workbook.Save("c:\\data\\HtmlStringtest.xlsx");
  18.  
  19. /*************** Following Code shows how to read html content ******************/
  20.  
  21. Workbook workbook2 = new Workbook("c:\\data\\HtmlStringtest.xlsx");
  22.  
  23. //Get first worksheet of workbook
  24. Worksheet worksheet2 = workbook.Worksheets[0];
  25.  
  26. //Get Cells in a Worksheet
  27. Cells cells2 = worksheet1.Cells;
  28.  
  29. //Get the individual cell
  30. Aspose.Cells.Cell cell2 = cells["A1"];
  31.  
  32. string html = cell2.HtmlString;

Report this snippet  

You need to login to post a comment.