セルから HTML5 文字列を取得
Contents
[
Hide
]
可能な使用シナリオ
Aspose.Cellsは、booleanパラメータを受け入れるGetHtmlStringメソッドを使って、セルのHTML文字列を返します。パラメータとしてfalseを渡すと、通常のHTMLを返し、trueを渡すと、HTML5文字列を返します。
セルからHTML5文字列を取得
次のサンプルコードはワークブックオブジェクトを作成し、最初のワークシートのセルA1にテキストを追加します。そして、GetHtmlStringメソッドを使用してセルA1から通常のHTMLとHTML5文字列を取得し、それらをコンソールに出力します。
サンプルコード
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 | |
//Create workbook. | |
Workbook wb = new Workbook(); | |
//Access first worksheet. | |
Worksheet ws = wb.Worksheets[0]; | |
//Access cell A1 and put some text inside it. | |
Cell cell = ws.Cells["A1"]; | |
cell.PutValue("This is some text."); | |
//Get the Normal and Html5 strings. | |
string strNormal = cell.GetHtmlString(false); | |
string strHtml5 = cell.GetHtmlString(true); | |
//Print the Normal and Html5 strings on console. | |
Console.WriteLine("Normal:\r\n" + strNormal); | |
Console.WriteLine(); | |
Console.WriteLine("Html5:\r\n" + strHtml5); |
コンソール出力
Normal:
<Font Style="FONT-FAMILY: Arial;FONT-SIZE: 10pt;COLOR: #000000;">This is some text.</Font>
Html5:
<div Style="FONT-FAMILY: Arial;FONT-SIZE: 10pt;COLOR: #000000;">This is some text.</div>