データテーブルへのセルのHTML文字列値のエクスポート
Contents
[
Hide
]
可能な使用シナリオ
Aspose.Cells API を使用すると、ワークシートデータをエクスポートしながら対応する HTML 文字列(セルの値に基づく)でデータテーブルを作成できます。このドキュメントでは、フォーマットされたセルデータのための HTML 文字列のエクスポート方法について説明しています。
セルのHTML文字列値をDataTableにエクスポート
以下のサンプルコードは、ワークシートから DataTable にデータをエクスポートする際にセルの HTML 文字列値を DataTable にエクスポートする方法を説明しています。サンプルエクセルファイル、そのスクリーンショット、および参照のためのコンソール出力をご覧ください。
スクリーンショット
サンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()); |
コンソール出力
<Font Style="FONT-FAMILY: Calibri;FONT-SIZE: 11pt;COLOR: #00b0f0;Background-Color: #ffe699;">Crow</Font>