Cell から HTML5 文字列を取得

考えられる使用シナリオ

Aspose.Cells は、セルの HTML 文字列を返します。getHtmlString(ブール値 html5)方法。合格すれば間違いパラメータとして、Normal HTML を返しますが、渡すと真実パラメータとして、HTML5 文字列を返します。

Cell から HTML5 文字列を取得

次のサンプル コードは、ブック オブジェクトを作成し、最初のワークシートのセル A1 にテキストを追加します。次に、セル A1 から通常の HTML と HTML5 文字列を取得します。getHtmlString(ブール値 html5)メソッドを実行し、それらをコンソールに出力します。

サンプルコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Create workbook.
Workbook wb = new Workbook();
//Access first worksheet.
Worksheet ws = wb.getWorksheets().get(0);
//Access cell A1 and put some text inside it.
Cell cell = ws.getCells().get("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.
System.out.println("Normal:\r\n" + strNormal);
System.out.println();
System.out.println("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>