كيفية إضافة علامة مائية إلى ورقة عمل في Excel
Contents
[
Hide
]
استخدم WordArt لإضافة تأثيرات نص أو صورة خاصة إلى جداول البيانات. على سبيل المثال، قم بتمدد عنوان عبر الجزء العلوي من الملف، وزين النص، واجعل النص يناسب شكلًا محددًا مسبقًا، أو ضع النص في ورقة Excel كخلفية مائية. يصبح WordArt كائنًا يمكنك تحريكه أو توضيبه في جداول البيانات لإضافة تزيين.
يوضح المثال التالي كيفية إضافة نص كـ WordArt لتعيين خلفية مائية لورقة العمل.
This file contains 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
Aspose::Cells::Startup(); | |
// Instantiate a new Workbook | |
Workbook wb; | |
// Get the first worksheet | |
WorksheetCollection wsc = wb.GetWorksheets(); | |
Worksheet ws = wsc.Get(0); | |
// Add Text Watermark | |
Shape wordart = ws.GetShapes().AddTextEffect(MsoPresetTextEffect::TextEffect1, | |
u"CONFIDENTIAL", u"Arial Black", 50, false, true | |
, 18, 8, 1, 1, 130, 800); | |
// Get the fill format of the word art | |
FillFormat wordArtFormat = wordart.GetFill(); | |
// Set the transparency | |
wordArtFormat.SetTransparency(0.9); | |
// Save the file | |
wb.Save(u"Watermark_Text.xlsx"); | |
Aspose::Cells::Cleanup(); |
The following example shows how to add a picture as WordArt to set a background watermark for a worksheet. ملف المصدر
This file contains 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
Aspose::Cells::Startup(); | |
//Path of input | |
U16String dirPath(u""); | |
//Path of output | |
U16String outPath(u""); | |
// Instantiate a new Workbook | |
Workbook wb; | |
// Get the first worksheet | |
WorksheetCollection wsc = wb.GetWorksheets(); | |
Worksheet ws = wsc.Get(0); | |
// open a file | |
std::ifstream fileStream(dirPath.ToUtf8() + "watermark.png", std::ios::binary); | |
if (!fileStream.is_open()) { | |
std::cerr << "Failed to open the file." << std::endl; | |
return 1; | |
} | |
// Get file size | |
fileStream.seekg(0, std::ios::end); | |
std::streampos fileSize = fileStream.tellg(); | |
fileStream.seekg(0, std::ios::beg); | |
// Read file contents into uint8_t array | |
uint8_t* buffer = new uint8_t[fileSize]; | |
fileStream.read(reinterpret_cast<char*>(buffer), fileSize); | |
fileStream.close(); | |
Vector<uint8_t>data(buffer, fileSize); | |
delete[] buffer; | |
// Set a picture as the Watermark. | |
ws.SetBackgroundImage(data); | |
// Save the file | |
wb.Save(outPath + u"Watermark_Pict.xlsx"); | |
Aspose::Cells::Cleanup(); |