Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing style is not same as reading #3

Open
j-catania opened this issue Feb 11, 2022 · 9 comments
Open

Writing style is not same as reading #3

j-catania opened this issue Feb 11, 2022 · 9 comments
Labels
question Further information is requested

Comments

@j-catania
Copy link

Hi everyone,

I don't understand why when I'am writing a simple XLSX file that I juste read, the writed file don't look the same ?

example code:

const url = 'assets/template.xlsx';
const tmplt = await (await fetch(url)).arrayBuffer();
/* data is an ArrayBuffer */
const workbook = XLSX.read(tmplt, {type: 'array', cellStyles: true});

XLSX.writeFile(workbook , `hello.xlsx`);

Realy thanks for your help,
Julien

@j-catania
Copy link
Author

I want to use a XLSX file like template, just add some raws for the data and keep the headers clean with all style.

@gitbrent
Copy link
Owner

What does the original file look like compared to the newly exported one? Do you have screencaps?

Also, I'm only just now updating the library to xlsx version 0.18.5 from 0.16 so that could be an issue as well.

@gitbrent gitbrent added the question Further information is requested label Mar 29, 2022
@Mathie01
Copy link

Mathie01 commented May 2, 2022

@gitbrent The style is not kept.

Source file :

image

Result :

image

@study9527
Copy link

When it reads xlsx, I can see the fgColor and bgColor property in s
console.log(sheet['A1'].s)
got example:
{ fgColor: { rgb: "FFD996"}, bgColor: {rgb: "FFFF00"}}

so I do something for workbook, add fill property to s, it work:

const workbook = XLSX.read(...);
const cell = workbook.Sheets[0]['A1'];
cell.s.fill = {
  fgColor: cell.s.fgColor,
  bgColor: cell.s.bgColor,
}

@masonlee
Copy link

masonlee commented Feb 7, 2023

Seeing the same! This is strange behavior or a bug, right? Otherwise, to preserve cell formatting when using this library to edit an existing xlxs, it is required to manually transform every cell.s property to the "write" format, as shown by @study9527 above?

@binbin
Copy link

binbin commented Feb 20, 2023

same question

@1MikeMakuch
Copy link

Same question.

@snowepiphany
Copy link

same question, the fill color can be modified manually, but the font style is not read

@jimmyliao11
Copy link

same question

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

9 participants