كيفية تغير خلفية التعليق في Excel باستخدام Node.js عبر C++
كيفية تغيير اللون في التعليق في إكسل
عندما لا تحتاج إلى لون خلفية افتراضي للتعليقات، قد ترغب في استبداله بلون تهتم به. كيف أغير لون خلفية صندوق التعليقات في Excel؟
سيقوم الكود التالي بإرشادك كيفية استخدام Aspose.Cells لإضافة لون خلفية مفضلة إلى التعليقات باختيارك الخاص.
لقد أعددنا لك ملف نموذجي. يُستخدم هذا الملف لتهيئة كائن Workbook في الشيفرة أدناه.
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
// Initialize a new workbook.
const workbook = new AsposeCells.Workbook(path.join(dataDir, "example.xlsx"));
// Accessing the newly added comment
const comment = workbook.getWorksheets().get(0).getComments().get(0);
// change background color
const shape = comment.getCommentShape();
shape.getFill().getSolidFill().setColor(AsposeCells.Color.Red);
// Save the Excel file
workbook.save(path.join(dataDir, "result.xlsx"));
قم بتشغيل الكود أعلاه وستحصل على ملف output file.
كيفية إدراج صورة أو صورة في التعليق في إكسل
يتيح Microsoft Excel للمستخدمين تخصيص مظهر وأسلوب جداول البيانات إلى حد كبير. من الممكن أيضًا إضافة صور خلفية إلى التعليقات. يمكن أن يكون إضافة صورة خلفية اختيارًا جماليًا أو يُستخدم لتعزيز العلامة التجارية.
ينشئ الكود أدناه ملف XLSX من الصفر باستخدام API Aspose.Cells، ويضيف تعليقًا بخلفية صورة إلى الخلية A1.
const AsposeCells = require("aspose.cells.node");
const path = require("path");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
// Instantiate a Workbook
const workbook = new AsposeCells.Workbook();
// Get a reference of comments collection with the first sheet
const comments = workbook.getWorksheets().get(0).getComments();
// Add a comment to cell A1
const commentIndex = comments.add(0, 0);
const comment = comments.get(commentIndex);
comment.setNote("First note.");
comment.getFont().setName("Times New Roman");
// Load an image into stream
const fs = require("fs");
const bmp = fs.readFileSync(path.join(dataDir, "image2.jpg"));
const ms = Buffer.from(bmp);
// Set image data to the shape associated with the comment
comment.getCommentShape().getFill().setImageData(ms);
// Save the workbook
const outputFilePath = path.join(dataDir, "commentwithpicture1.out.xlsx");
workbook.save(outputFilePath, AsposeCells.SaveFormat.Xlsx);