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

Formatting dates format with (*excelize.Rows).Columns #1722

Open
maks56893 opened this issue Nov 15, 2023 · 6 comments
Open

Formatting dates format with (*excelize.Rows).Columns #1722

maks56893 opened this issue Nov 15, 2023 · 6 comments

Comments

@maks56893
Copy link

maks56893 commented Nov 15, 2023

Hello, i have different date format in sheet. It's possible to format dates to one format when i iterating with rows and get rows values with (*excelize.Rows).Columns or i should check every cell for date type and rewrite style for date type cells?

@xuri
Copy link
Member

xuri commented Nov 16, 2023

You can create a style with date format by the NewStyle function at first, you will get a style index, then set the cell's style with style ID by the SetRowStyle function to change the all cell's styles in a row.

@maks56893
Copy link
Author

maks56893 commented Nov 16, 2023

It wiil override all cells in row with number type. In addition to dates, I also have regular numbers in row. This method doesn't fit

@xuri
Copy link
Member

xuri commented Nov 17, 2023

If the types of cells in a row are not all date, you need to set the style of the specified cells one by one with the SetCellStyle function, but you can make these cells use the same style index.

@maks56893
Copy link
Author

maks56893 commented Nov 20, 2023

Okay. To set style only for date types cells, i need to check every cell for it's type with GetCellType and then i can use SetCellStyle. But with this case it's consumes a lot of ram (+2gb for 300k rows file and 15 columns). Probably this relates with new reader for every call of GetCellType and SetCellStyle.

@maks56893
Copy link
Author

So, what I can do with it?

@xuri
Copy link
Member

xuri commented Dec 6, 2023

Currently, please set the date type cell style one by one with the SetCellStyle function. I will consider to improve performance for this.

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

No branches or pull requests

2 participants