Exportera HTML strängvärde av cellerna till DataTable

Möjliga användningsscenario

Med Aspose.Cells API kan utvecklare fylla en DataTable med motsvarande HTML-strängar (baserat på cellvärden) vid export av arbetsbladsdata. Denna dokumentation förklarar hur man exporterar HTML-strängar för de formaterade cellvärdena för att fylla en DataTable med hjälp av Aspose.Cells API.

Exportera HTML-strängvärde av celler till DataTable

Följande exempelkod illustrerar hur man exporterar HTML-strängvärde av cellerna till DataTable vid export av data från arbetsblad till DataTable. Se den exempel-Excel-filen, dess skärmbild och konsoloutput för referens.

Skärmdump

todo:image_alt_text

Exempelkod

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load sample Excel file
Workbook wb = new Workbook(sourceDir + "sampleExportTableAsHtmlString.xlsx");
//Access first worksheet
Worksheet ws = wb.Worksheets[0];
//Specify export table options and set ExportAsHtmlString to true
ExportTableOptions opts = new ExportTableOptions();
opts.ExportColumnName = false;
opts.ExportAsHtmlString = true;
//Export the cells data to data table with the specified export table options
DataTable dt = ws.Cells.ExportDataTable(0, 0, 3, 3, opts);
//Print the cell html string value that is in third row and second column
Console.WriteLine(dt.Rows[2][1].ToString());

Konsoloutput

 <Font Style="FONT-FAMILY: Calibri;FONT-SIZE: 11pt;COLOR: #00b0f0;Background-Color: #ffe699;">Crow</Font>