Posted 16 November 2022, 11:14 pm EST
When importing a file it is working.
But if I add an incremental loading it doesn’t work.
Code without loading:
mergeJSON = (json, result) => {
const spreadExcel = new GC.Spread.Sheets.Workbook();
const estilo = result.opcoes.estilo;
const formula = result.opcoes.formula;
const calcularFormula = result.opcoes.calcularFormula;
const linha = result.opcoes.linha;
const coluna = result.opcoes.coluna;
spreadExcel.fromJSON(json, {
ignoreStyle: estilo,
ignoreFormula: formula,
frozenColumnsAsRowHeaders: coluna,
frozenRowsAsColumnHeaders: linha,
doNotRecalculateAfterLoad: calcularFormula,
});
spreadExcel.sheets.forEach((sheet) => {
const nome = this.adicionaNovaPaginaNaPlanilha(sheet);
this.nomeDasAbas.push(nome);
});
spreadExcel.getNamedStyles().forEach((style) => this.workbook.addNamedStyle(style));
const nomeCelulas = json.names as NomeCelula[];
if (nomeCelulas && nomeCelulas.length > 0) {
nomeCelulas.forEach((nomeCelula) =>
this.workbook.addCustomName(nomeCelula.name, nomeCelula.formula, nomeCelula.row, nomeCelula.col, nomeCelula.comment)
);
}
this.loading = false;
};
Code with loading:
mergeJSON = (json, result) => {
const spreadExcel = new GC.Spread.Sheets.Workbook();
const estilo = result.opcoes.estilo;
const formula = result.opcoes.formula;
const calcularFormula = result.opcoes.calcularFormula;
const linha = result.opcoes.linha;
const coluna = result.opcoes.coluna;
spreadExcel.fromJSON(json, {
ignoreStyle: estilo,
ignoreFormula: formula,
frozenColumnsAsRowHeaders: coluna,
frozenRowsAsColumnHeaders: linha,
doNotRecalculateAfterLoad: calcularFormula,
incrementalLoading: {
loading: function (progress, _) {
progress = progress * 100;
document.getElementById('statusBar').innerText = 'Loading: ' + progress.toFixed(2) + '%';
},
loaded: function () {
document.getElementById('statusBar').innerText = 'Finish';
},
},
});
spreadExcel.sheets.forEach((sheet) => {
const nome = this.adicionaNovaPaginaNaPlanilha(sheet);
this.nomeDasAbas.push(nome);
});
spreadExcel.getNamedStyles().forEach((style) => this.workbook.addNamedStyle(style));
const nomeCelulas = json.names as NomeCelula[];
if (nomeCelulas && nomeCelulas.length > 0) {
nomeCelulas.forEach((nomeCelula) =>
this.workbook.addCustomName(nomeCelula.name, nomeCelula.formula, nomeCelula.row, nomeCelula.col, nomeCelula.comment)
);
}
this.loading = false;
};
private adicionaNovaPaginaNaPlanilha(sheet: GC.Spread.Sheets.Worksheet): string {
const nome = this.checaSeJaExisteAbaComNome(sheet.name());
sheet.name(nome);
const index = this.workbook.sheets.length;
this.workbook.addSheet(index, sheet);
return nome;
}