Esporta il valore della stringa HTML delle celle nella tabella
Possibili Scenari di Utilizzo
Utilizzando le API di Aspose.Cells, gli sviluppatori possono riempire una DataTable con stringhe HTML corrispondenti (basate sui valori delle celle) durante l’esportazione dei dati del foglio di calcolo. Questo documento spiega come esportare le stringhe HTML per i dati delle celle formattate per riempire una DataTable utilizzando le API di Aspose.Cells.
Esporta il valore della stringa HTML delle celle nel DataTable
Il seguente codice di esempio illustra come esportare il valore della stringa HTML delle celle nella tabella durante l’esportazione dei dati dal foglio di calcolo nella DataTable. Si prega di consultare il file di Excel di esempio, la sua schermata e l’output della console per un riferimento.
Screenshot
Codice di Esempio
// 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()); |
Output della console
<Font Style="FONT-FAMILY: Calibri;FONT-SIZE: 11pt;COLOR: #00b0f0;Background-Color: #ffe699;">Crow</Font>