カスタム(hexcodeまたはrgb値から)の色をxssfcellに設定しようとしています。他の色を付けても、セルの色が黒くなっています。私は、次の方法でこれをやって試してみました:XSSFCell Apache POIでカスタム色を設定できません
File xlSheet = new File("C:\\Users\\IBM_ADMIN\\Downloads\\Excel Test\\Something3.xlsx");
System.out.println(xlSheet.createNewFile());
FileOutputStream fileOutISPR = new FileOutputStream("C:\\Users\\IBM_ADMIN\\Downloads\\Excel Test\\Something3.xlsx");
XSSFWorkbook isprWorkbook = new XSSFWorkbook();
XSSFSheet sheet = isprWorkbook.createSheet("TEST");
XSSFRow row = sheet.createRow(0);
XSSFCellStyle cellStyle = isprWorkbook.createCellStyle();
byte[] rgb = new byte[3];
rgb[0] = (byte) 24; // red
rgb[1] = (byte) 22; // green
rgb[2] = (byte) 219; // blue
XSSFColor myColor = new XSSFColor(rbg);
cellStyle.setFillForegroundColor(myColor);
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellStyle.setAlignment(HorizontalAlignment.CENTER);
XSSFCell cell = row.createCell(0);
cell.setCellValue("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has");
cell.setCellStyle(cellStyle);
CellRangeAddress rangeAddress = new CellRangeAddress(0, 0, 0, 2);
sheet.addMergedRegion(rangeAddress);
int width = ((int)(90 * 0.73)) * 256;
sheet.setColumnWidth(cell.getColumnIndex(), width);
//sheet.autoSizeColumn(cell.getColumnIndex());
RegionUtil.setBorderBottom(XSSFCellStyle.BORDER_MEDIUM, rangeAddress, sheet, isprWorkbook);
RegionUtil.setBottomBorderColor(IndexedColors.RED.getIndex(), rangeAddress, sheet, isprWorkbook);
XSSFCell cell2 = row.createCell(11);
cell2.setCellValue("222222222222222");
isprWorkbook.write(fileOutISPR);
//プログラム
XSSFCellStyle cellStyle = isprWorkbook.createCellStyle();
byte[] rgb = new byte[3];
rgb[0] = (byte) 24; // red
rgb[1] = (byte) 22; // green
rgb[2] = (byte) 219; // blue
XSSFColor myColor = new XSSFColor(rgb);
cellStyle.setFillForegroundColor(myColor);//1st method
//cellStyle.setFillForegroundColor(new XSSFColor(new java.awt.Color(128, 0, 128)));//2nd method
//XSSFColor myColor = new XSSFColor(Color.decode("0XFFFFFF"));
cellStyle.setFillForegroundColor(myColor);//3rd Method
のEND私は他の多くの関連の質問への回答に記載の方法が、私の問題を解決し、それらのどれを試してみました。 私を助けてください。
ここは朝ですが、1と3の違いは何ですか?私はあなたが塗りつぶしパターンがないと思う、https://stackoverflow.com/a/31671032/180100を参照してください –
確かに、私は最小限のコードで質問を更新します。ありがとう – Pranjal
塗りつぶしパターンは、パターンは色が設定された後でも完全な白である行方不明だった。しかし、私の場合、フルセルは黒です。 – Pranjal