العمل مع الألوان في Apache POI و Aspose.Cells
Contents
[
Hide
]
Aspose.Cells - التعامل مع الألوان
Aspose.Cells يوفر فصل دراسي ،دفتر العمل، يمثل ملف Excel Microsoft. تحتوي فئة المصنف على مجموعة أوراق العمل التي تتيح الوصول إلى كل ورقة عمل في ملف Excel. يتم تمثيل ورقة العمل بواسطةورقة عملصف دراسي. توفر فئة ورقة العمل مجموعة الخلايا. يمثل كل عنصر في مجموعة Cells عنصرًا من عناصرCellصف دراسي.
يوفر Aspose.Cells طريقة setStyle في فئة Cell المستخدمة لضبط تنسيق الخلية. أيضًا ، يمكن استخدام كائن النمط لفئة النمط لتكوين إعدادات الخط.
Java
//Accessing cell from the worksheet
Cell cell = cells.get("B2");
Style style = cell.getStyle();
//Setting the foreground color to yellow
style.setBackgroundColor(Color.getYellow());
//Setting the background pattern to vertical stripe
style.setPattern(BackgroundType.VERTICAL_STRIPE);
//Saving the modified style to the "A1" cell.
cell.setStyle(style);
// === Setting Foreground ===
//Adding custom color to the palette at 55th index
Color color = Color.fromArgb(212,213,0);
workbook.changePalette(color,55);
//Accessing cell from the worksheet
cell = cells.get("B3");
//Adding some value to the cell
cell.setValue("Hello Aspose!");
//Setting the custom color to the font
style = cell.getStyle();
Font font = style.getFont();
font.setColor(color);
cell.setStyle(style);
Apache POI SS - HSSF XSSF - العمل مع الألوان
تتوفر فئة CellStyle لتعيين إعدادات الخلفية ونمط التعبئة.
Java
// Aqua background
CellStyle style = wb.createCellStyle();
style.setFillBackgroundColor(IndexedColors.AQUA.getIndex());
style.setFillPattern(CellStyle.BIG_SPOTS);
Cell cell = row.createCell((short) 1);
cell.setCellValue("X");
cell.setCellStyle(style);
// Orange "foreground", foreground being the fill foreground not the font color.
style = wb.createCellStyle();
style.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
cell = row.createCell((short) 2);
cell.setCellValue("X");
cell.setCellStyle(style);
قم بتنزيل كود التشغيل
تنزيل نموذج التعليمات البرمجية
- [جيثب](https://github.com/aspose-cells/Aspose.Cells-for-Java/tree/master/Plugins/Aspose_Cells_for_Apache_POI/Aspose-Cells-for-Apache-POI-(Maven)/ src / main / java / com / aspose / cells / أمثلة / featurescomparison / formatting / colours)
لمزيد من التفاصيل ، قم بزيارةالألوان وأنماط الخلفية.