I’ve tried to create FontSettings for cells and found, that it contains very unexpected third parameter - WorksheetCollection. Are you sure, that it is correct?
new FontSetting(start, length, source.getWorksheet().getWorkbook().getWorksheets());
Best regards. Alexey
@makarovalv,
Yes, the third parameter is WorksheetCollection and we are aware of it. This refers to the underling FontSetting for which workbook, we will provide more details on it.
I used the following sample code and it works fine and as expected:
e.g
Sample code:
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
worksheet.setName("Test");
worksheet.getCells().get("A1").setValue("Test combined font style bold and strikeout");
// First testcase: first call sets the IsBold property, second call sets the IsStrikeout property
Cell cell = worksheet.getCells().get("A2");
String text = "Bold StrikethroughBold Bold";
cell.setValue(text);
cell.characters(0, text.length()).getFont().setBold(true);
cell.characters(5, "StrikethroughBold".length()).getFont().setStrikeout(true);
// Second testcase: just turn around the call sequence of IsStrikeout and IsBold
Cell cell2 = worksheet.getCells().get("A3");
String text2 = "Bold StrikethroughBold Bold evaluation";
cell2.setValue(text2);
//Create first font setting object
FontSetting fs1 = new FontSetting(5, "StrikethroughBold".length(), workbook.getWorksheets());
//Set the font srike out
fs1.getFont().setStrikeout(true);
//Create second font settting object
FontSetting fs2 = new FontSetting(0, text2.length(), workbook.getWorksheets());
//Set the font srike out
fs2.getFont().setBold(true);
//Set the font settings via SetCharacters method
cell2.setCharacters(new FontSetting[] { fs1, fs2 });
workbook.save("e:\\test2\\out1.xlsx", SaveFormat.XLSX);
Hope, this helps a bit.