-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
set column widths and date format #52
Conversation
and here's how it looks for me... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backend/pkg/reporter/reporter.go
Outdated
func floatToDateString(value interface{}) (string, bool) { | ||
var date string | ||
|
||
// dates are returned as float64 values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why.. lol!
backend/pkg/reporter/reporter.go
Outdated
func (r *Report) writeCell(sheetName string, cellRef string, value interface{}) { | ||
if date, ok := floatToDateString(value); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was having this return false
for invoice_printed_date
on a [transact]
, which meant no alignment:
I looked a little, but I wasn't able to figure it out. I tried changing the condition which uses milliseconds to using a seconds unix epoch but no dice!
Was hoping to compare the invoice_printed_date
field with the one/ones you're using to see if that will uncover the problem!
backend/pkg/reporter/reporter.go
Outdated
|
||
if len(columns) > 0 { | ||
for columnNumber, column := range columns { | ||
maximumContentLengths[columnNumber] = headerFontCorrectionFactor * float64(len(column.Text)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Headers were a little crammed if the content didn't; surpass the header width: Maybe a little bit of padding? len(column.Text)+3
backend/pkg/reporter/reporter.go
Outdated
headerFontCorrectionFactor := 1.35 | ||
maximumContentLengths := make(map[int]float64) | ||
|
||
if len(columns) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if seems redundant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, removed
awesome! thanks @joshxg - both for the review and the inspiration to test against the have vertically aligned the numbers, fixed the heading padding and catered for ALL UPPERCASE STRING VALUES TOO. |
PERFECT |
fixes #49
This sets columns widths based on header and row content, using the current font in the template it looks great. There's no guarantee this will always be the case, but it works for now.
Have also formatted dates - which are helpfully returned as float64 values. The parsing is a bit iffy, but once again, it works.
You'll need to update the template ( attached ) as I've merged the date cell so that it looks fine when column 1 is not so wide.
template.xlsx