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

Column formatting working in Libreoffice, not excel 365 #368

Open
akobberup opened this issue Dec 12, 2023 · 1 comment
Open

Column formatting working in Libreoffice, not excel 365 #368

akobberup opened this issue Dec 12, 2023 · 1 comment

Comments

@akobberup
Copy link

akobberup commented Dec 12, 2023

I create a file with 4 columns formatted as datetime, date, number and decimal.

When opening in excel (online) the columns are not formatted:
image

When opening in libreoffice it works.
image

If i open the file in libreoffice and saves it, then the formatting will work in excel when opened there.
image

Here is the styling routine i use:

		for (int index = 0; index < headerElements.size(); index++) {
			final HeaderElement dataElement = headerElements.get(index);
			ColumnStyleSetter style = worksheet.style(index);
			style.fontSize(10);
			switch (dataElement.getDataType()) {
				case Boolean:
					style.horizontalAlignment("center");
					break;
				case String:
					break;
				case Number:
					style.horizontalAlignment("right");
					style.format("#,##0");
					break;
				case Decimal:
					style.horizontalAlignment("right");
					style.format("#,##0.00");
					break;
				case Date:
					style.format("yyyy/mm/dd");
					break;
				case DateTime:
					style.format("yyyy/mm/dd HH:mm");
					break;
			}
			style.set();
		}

Edit: Just to clarify, I'm danish, and we use period for thousand separator and comma as decimal separator :)

test5581114334280939970.xlsx

@MrAlucardDante
Copy link

I encountered the same issue.
Setting the style both with ColumeStyleSetter and StyleSetter (on each cell) worked in both Excel and LibreOffice
For instance :

ws.style(row, column).format(date_format).set();
ws.style(column).format(date_format).set();

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