Exportieren Sie den HTML String Wert der Zellen in die DataTable

Mögliche Verwendungsszenarien

Mit den Aspose.Cells-APIs können Entwickler eine DataTable mit entsprechenden HTML-Strings (basierend auf Zellenwerten) füllen, während sie Daten aus einem Arbeitsblatt exportieren. In diesem Dokument wird erläutert, wie HTML-Strings für die formatierten Zellendaten exportiert werden, um eine DataTable mit den Aspose.Cells-APIs zu füllen.

Exportieren Sie den HTML-Stringwert der Zellen in die DataTable

Das folgende Beispielcode veranschaulicht, wie der HTML-String-Wert der Zellen in die DataTable exportiert wird, während Daten aus dem Arbeitsblatt in die DataTable exportiert werden. Bitte sehen Sie sich die Beispiel-Excel-Datei, deren Bildschirmfoto und die Konsolenausgabe als Referenz an.

Screenshot

todo:image_alt_text

Beispielcode

// 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());

Konsolenausgabe

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