The sheet.js library allows you to create and edit spreadsheets of type xlsx
d Open office
. Currently I have a spreadsheet that contains 3 pages as shown in the figure below.
The DADOS
page contains information that will be used by the Gráfico 1
and Gráfico 2
pages.
The Gráfico 1
page contains a formatting that graphically displays the data contained in the DADOS
page, as well as contains mathematical accounts that work with the page DADOS
ex. =DADOS.A1/Gráfico1.B2
.
To edit a worksheet using sheet.js and use the following code.
if(typeof require !== 'undefined') XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
/* o workbook representa tudo no arquivo XLSX */
// Através da variavel workbook eu consigo ter
// controle de paginas, linhas, colunas e etc
XLSX.writeFile(workbook, 'out.xlsx');
Note that in the code I use the command XLSX.writeFile(workbook, 'out.xlsx');
to generate a new file xlsx
which in theory should not have anything different than the test.xlsx
worksheet from which it originates.
The problem I am facing is that when a new file is generated it loses the formulas contained in the cells of the original worksheet, in the Gráfico 1
page where it had the formula =DADOS.A1/Gráfico1.B2
, it only has the result of the formula, clicking on the cell to edit does not appear the same formula in the original worksheet, and any formatting that the worksheet contained and lost.
I need help saving this worksheet and keeping the formulas and formatting contained in the original.