ضبط ظل تأثير النص الخاص بالشكل أو مربع النص باستخدام جافا سكريبت عبر C++
Contents
[
Hide
]
يمكنك ضبط ظل تأثيرات النص لأي شكل أو مربع نص. يرجى استخدام خاصية Shape.textBody. تقدم إعداد النص الخاص بالشكل وتعيد كائنات من نوع FontSetting. بعد الوصول إليه، يرجى ضبط الظل عبر خاصية FontSetting.presetType. هذه الخاصية من نوع PresetShadowType الذي يحتوي على عدة قيم. بعض هذه القيم:
- إزاحة قطرية لأسفل اليمين
- إزاحة لأسفل
- إزاحة قطرية لأعلى اليمين
- داخل اليسار
- داخل الوسط
- زاوية رؤية قطرية العلوي الأيسر
- زاوية رؤية قطرية السفلي الأيمن
يُظهر مقتطف الكود التالي استخدام خاصية FontSetting.presetType لضبط ظل تأثيرات النص في الشكل أو مربع النص.
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
</head>
<body>
<h1>Aspose.Cells: Set Text Effects Shadow of Shape or Textbox</h1>
<input type="file" id="fileInput" accept=".xls,.xlsx,.csv" />
<button id="runExample">Run Example</button>
<a id="downloadLink" style="display: none;">Download Result</a>
<div id="result"></div>
</body>
<script src="aspose.cells.js.min.js"></script>
<script type="text/javascript">
const { Workbook, SaveFormat, PresetShadowType, Color } = AsposeCells;
AsposeCells.onReady({
license: "/lic/aspose.cells.enc",
fontPath: "/fonts/",
fontList: [
"arial.ttf",
"NotoSansSC-Regular.ttf"
]
}).then(() => {
console.log("Aspose.Cells initialized");
});
document.getElementById('runExample').addEventListener('click', async () => {
// Create workbook object
const wb = new Workbook();
// Access first worksheet
const ws = wb.worksheets.get(0);
// Add text box with these dimensions
const tb = ws.shapes.addTextBox(2, 0, 2, 0, 100, 400);
// Set the text of the textbox
tb.text = "This text has the following settings.\n\nText Effects > Shadow > Offset Bottom";
// Set all the text runs shadow to preset offset bottom
const textBody = tb.textBody;
for (let i = 0; i < textBody.count; i++) {
const textRun = textBody.get(i);
textRun.textOptions.shadow.presetType = PresetShadowType.OffsetBottom;
}
// Set the font color and size of the textbox
tb.font.color = Color.Red;
tb.font.size = 16;
// Save the output file
const outputData = wb.save(SaveFormat.Xlsx);
const blob = new Blob([outputData]);
const downloadLink = document.getElementById('downloadLink');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = 'outputSettingTextEffectsShadowOfShapeOrTextbox.xlsx';
downloadLink.style.display = 'block';
downloadLink.textContent = 'Download Excel File';
document.getElementById('result').innerHTML = '<p style="color: green;">Workbook created. Click the download link to get the file.</p>';
});
</script>
</html>