怎么给单个cell设置背景色为黄色,试了几个api都不行

怎么给单个cell设置背景色为黄色,试了几个api都不行

@liufei951027
请检查帖子 How to color a cell using ARGB?

@liufei951027,

另请参阅有关如何将工作表中单个单元格的背景/底纹颜色设置为“黄色”的示例代码以供参考。
e.g.

//Instantiate a new Workbook
Workbook workbook = new Workbook();
//Get the first worksheet (default worksheet)
Worksheet worksheet = workbook.getWorksheets().get(0);
//Get the worksheet cells (collection)
Cells cells = worksheet.getCells();
//Get the C4 cell
Cell cell = cells.get("C4");
//Get the style of the cell
Style style = cell.getStyle();
//Set cell fill/shading/background color to yellow
style.setPattern(BackgroundType.SOLID);
style.setForegroundColor(com.aspose.cells.Color.getYellow());
cell.setStyle(style);

//Save the Excel file
workbook.save("f:\\files\\out1.xlsx");

希望这对您有帮助。