Pivot Data Mismatch Between Excel Workbook and Generated HTML (Aspose.Cells)

const htmlAsposeTempFile = path.join(
process.cwd(),
htmlaspose_${crypto.randomUUID()}.html
);
let finalHtml = null;
try {
finalHtml = await saveWorkbookAsHtml(workbook, htmlAsposeTempFile);
} catch (htmlErr) {
LOGGER.error([saveWorkbookAsHtml] failed , htmlErr);
return null;
}

i observed its failing when we add date fields

@KarthikMunjam,

Thanks for sharing details.

We will evaluate your issue (CELLSNODEJSJAVA-81) and try to figure it out. Once we have new updates, we will let you know.

@KarthikMunjam
The original file “ExcelPivotFailure.xlsx” is corrupted because there is an unnecessary blank item in date group field.
It’s better that you can share a sample project to show to how to create ExcelPivotFailure.xlsx.
If ExcelPivotFailure.xlsx is generated by Aspose.Cells, we will try to make it work too.
Of course, we will try to fix this issue of null exception too.

@KarthikMunjam
Please ignore my previous posts.
The template file ExcelPivotFailure must be generated by Aspose.Cells.

I, We provide a new group method PivotField.GroupBy(PivotGroupByType[] groups, double interval, bool firstAsNewField) , then you do not need to assign start and end date time value.
2, We will add PivotField.MaxValue and PivotField.MinValue, then you can adjust and set the start and end time according them.
Then you can recreate your ExcelPivotFailure .xlsx template file.

sorry @simon.zhao / @amjad.sahi can you please share the working code

this is my current code ::

function saveWorkbookAsHtml(workBook, fileName) {
const sheets = workBook.getWorksheets();
const sheetcount = sheets.getCount();
for (let i = 0; i < sheetcount; i++) {
const sheet = sheets.get(i);
if (sheet.getName() !== CONSTWORKSHEET.PIVOT) {
sheet.setVisible(false);
} else {
const pivots = sheet.getPivotTables();
const pivotcount = pivots.getCount();
for (let j = 0; j < pivotcount; j++) {
const pivot = pivots.get(j);

            pivot.refreshData();
            pivot.calculateData();
        }
    }
}

workBook.calculateFormula();

const saveOptions = new aspose.cells.HtmlSaveOptions();
saveOptions.setExportActiveWorksheetOnly(true);
saveOptions.setPresentationPreference(true);
saveOptions.setExportGridLines(true);

workBook.save(fileName, saveOptions);

}

@KarthikMunjam
If you want to refresh all pivot tables, you only need to call sheets.refreshAll() method .
We have fixed some issue refreshing pivot tables in ExcelPivotFailure.xlsx.
But we need more time to check how to refresh group field, so if a new Aspose.Cells is released, it’s better that you can PivotField.GroupBy(PivotGroupByType[] groups, double interval, bool firstAsNewField) to group date field when creating ExcelPivotFailure.xlsx.

we are using

const java = require(‘java’);
const [minDate, maxDate] = [1900, 2100];

    const javaIntArray = (array) => java.newArray('int', array);
    const startDate = aspose.cells.DateTime(minDate, 1, 1);
    const endDate = aspose.cells.DateTime(maxDate, 1, 1);
    const groupingArray = javaIntArray(dateGroups);
    pivotField.groupBy(startDate, endDate, groupingArray, 1, false);

we are using pivotField.groupBy only

@KarthikMunjam
Yes. There is a bug when using pivotField.groupBy(startDate, endDate, groupingArray, 1, false); to group the field which contains an empty pivot item. We will fix it soon.
And in the next version, we will provide pivotField.groupBy(groupingArray, 1, false); method which will auto detect the min and max date time in the pivot field.

ok thank you , by when can i expect a fix for this?

@KarthikMunjam,

You may expect the fix either in v25.12 or v26.1 which will be published in the first half of December 2025 or January 2026 (next month). We will update you once we release the supported version.

The issues you have found earlier (filed as CELLSNODEJSJAVA-81) have been fixed in this update. This message was posted using Bugs notification tool by duojie.yang