احصل على سلسلة HTML5 من Cell

سيناريوهات الاستخدام الممكنة

تقوم Aspose.Cells بارجاع سلسلة HTML للخلية باستخدامgetHtmlString (قيمة منطقية html5)طريقة. إذا مررتخاطئةكمعامل ، سيعود لك HTML عادي ولكن إذا نجحتحقيقيكمعامل ، فإنه سيعيد سلسلة HTML5.

احصل على سلسلة HTML5 من Cell

نموذج التعليمات البرمجية التالي ينشئ كائن مصنف ويضيف بعض النص في الخلية A1 من ورقة العمل الأولى. ثم تحصل على السلسلة العادية HTML و HTML5 من الخلية A1 باستخدام امتداد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>