java file seem not to get attached.
Here the code of the testcase:
*import* java.io.File;
*import* org.apache.poi.ss.usermodel.Sheet;
*import* org.apache.poi.ss.usermodel.Workbook;
*import* org.apache.poi.ss.usermodel.WorkbookFactory;
*import* org.apache.poi.xssf.usermodel.XSSFSheet;
*public* *class* ReadPoi {
*public* *static* *final* String *XLSX_FILE_PATH* =
"/Users/eduardo/Desktop/jxls-issue/conditional_formatting_issue_ok.xlsx";
*public* *static* *void* main(String[] args) *throws* Exception {
Workbook workbook = WorkbookFactory.*create*(*new* File(
*XLSX_FILE_PATH*));
*for* (Sheet sheet : workbook) {
XSSFSheet xsheet = (XSSFSheet) sheet;
System.*out*.println(sheet.getSheetName() + " has "
+
xsheet.getSheetConditionalFormatting().getNumConditionalFormattings()
+ " conditional formattings");
}
}
}
Am So., 25. Apr. 2021 um 15:01 Uhr schrieb Eduardo Eduardo <
[email protected]>:
> Hi,
>
> reading the number of conditional formatting via getNumConditionalFormattings
> is only working if the condition references cells in the same sheet.
>
> Attached two simple Excel files and a simple testcase:
>
> If you run it with "conditional_formatting_issue.xlsx", you see this
> ouput:
>
> Tabelle1 has 0 conditional formattings
>
> MyData has 0 conditional formattings
>
>
> here you see that conditional formattings were not correctly read,
> although there is one (referencing another sheet).
>
>
> If the conditional formatting references same sheet (
> conditional_formatting_issue_ok.xlsx), I get the output:
>
> Tabelle1 has 1 conditional formattings
>
>
> which shows that in this case it works.
>
>
> I tested both with POI 4.1.2 and POI 5.0.0
>
>
>