الحصول على سلسلة HTML5 من الخلية
سيناريوهات الاستخدام المحتملة
يعيد Aspose.Cells السلسلة HTML للخلية باستخدام طريقة Cell.getHtmlString(boolean) التي تقبل معيار boolean. إذا مررت false كمعامل، فسيعود بـ HTML عادي، وإذا مررت true، فسيعود بسلسلة HTML5.
الحصول على سلسلة HTML5 من الخلية
يقوم رمز العينة التالي بإنشاء كائن دفتر عمل ويضيف بعض النص إلى الخلية A1 من ورقة العمل الأولى. ثم يحصل على سلاسل HTML العادية وHTML5 من الخلية A1 باستخدام طريقة Cell.getHtmlString(boolean) ويطبعها على وحدة التحكم.
الكود المثالي
const AsposeCells = require("aspose.cells.node"); | |
const path = require("path"); | |
// The path to the documents directory. | |
const dataDir = path.join(__dirname, "data"); | |
// Create workbook. | |
const wb = new AsposeCells.Workbook(); | |
// Access first worksheet. | |
const ws = wb.getWorksheets().get(0); | |
// Access cell A1 and put some text inside it. | |
const cell = ws.getCells().get("A1"); | |
cell.putValue("This is some text."); | |
// Get the Normal and Html5 strings. | |
const strNormal = cell.getHtmlString(false); | |
const strHtml5 = cell.getHtmlString(true); | |
// Print the Normal and Html5 strings on console. | |
console.log("Normal:\r\n" + strNormal); | |
console.log(); | |
console.log("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>