إدارة سلاسل HTML للخلايا
Contents
[
Hide
]
سيناريوهات الاستخدام المحتملة
عندما تحتاج إلى تعيين بيانات منسقة لخلية معينة، يمكنك تعيين نص HTML للخلية. بالطبع، يمكنك أيضًا الحصول على نص HTML الخاص بالخلية. توفر Aspose.Cells for Node.js via C++ هذه الميزة. تقدم Aspose.Cells الخصائص والطرق التالية لمساعدتك على تحقيق أهدافك.
الحصول على وتعيين نص HTML باستخدام Aspose.Cells for Node.js via C++
يوضح هذا المثال كيف:
- إنشاء دفتر عمل وإضافة بعض البيانات.
- الحصول على الخلية المحددة في ورقة العمل الأولى.
- تعيين سلسلة HTML في الخلية.
- الحصول على سلسلة HTML للخلية.
This file contains hidden or 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
const AsposeCells = require("aspose.cells.node"); | |
const path = require("path"); | |
// The path to the documents directory. | |
const dataDir = path.join(__dirname, "data"); | |
// Instantiating a Workbook object | |
let workbook = new AsposeCells.Workbook(); | |
// Obtaining the reference of the newly added worksheet | |
let ws = workbook.getWorksheets().get(0); | |
let cells = ws.getCells(); | |
// Setting the value to the cells | |
let cell = cells.get("A1"); | |
cell.putValue("Fruit"); | |
cell = cells.get("B1"); | |
cell.putValue("Count"); | |
cell = cells.get("C1"); | |
cell.putValue("Price"); | |
cell = cells.get("A2"); | |
cell.putValue("Apple"); | |
cell = cells.get("A3"); | |
cell.putValue("Mango"); | |
cell = cells.get("A4"); | |
cell.putValue("Blackberry"); | |
cell = cells.get("A5"); | |
cell.putValue("Cherry"); | |
let c3 = cells.get("C3"); | |
// set html string for C3 cell. | |
c3.setHtmlString("<b>test bold</b>"); | |
let c4 = cells.get("C4"); | |
// set html string for C4 cell. | |
c4.setHtmlString("<i>test italic</i>"); | |
// get the html string of specific cell. | |
console.log(c3.getHtmlString()); | |
console.log(c4.getHtmlString()); |
الإخراج الذي تم توليده بواسطة رمز العينة
تُظهر اللقطة الشاشية التالية الإخراج الناتج من الكود المثالي السابق.