mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 22:02:06 -06:00
[GH-ISSUE #120] How to iterate for best performance #100
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#100
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jeroen on GitHub (Aug 21, 2017).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/120
Originally assigned to: @jmcnamara on GitHub.
The examples iterate over rows first, and within each row over the fields. Is it also possible to fill the sheet column-wise, or is this much slower? Column wise is often easier and faster to implement if the original data have typed columns (e.g. sql tables).
Additional question: if I know in advance the that the data is
nbymis there an option to preallocate thelxw_worksheetof the right size, rather than dynamically growing it?@jmcnamara commented on GitHub (Aug 21, 2017):
Hi Jeroen,
The worksheet cell data is stored in Red-Black trees by row so iterating by row is faster. And when using
constant_memorymode you have to write the data in row x column order.Unfortunately not. As usual the choice of internal data structure is a trade off. For ease of use libxlsxwriter, and for sparse data, the data is stored in Red-Black trees which can't be preallocated ahead of time.
Regards,
John
@jeroen commented on GitHub (Aug 21, 2017):
OK that makes sense thank you. One final performance question:
My input timestamps are stored as (standard unix) double with seconds since 1970-01-01 00:00:00. From your documentation I read that excel also uses doubles but a different scale:
Is there an obvious way to insert unix doubles as dates without first converting everything to
lxw_datetimestructs?@jmcnamara commented on GitHub (Aug 21, 2017):
Excel dates are stored as an integer and fraction part where the integer part is the number of days since the Excel epoch (~1/1/1900) and the fractional part is time as the percentage of the day in seconds.
So to convert from Unix time (seconds since Unix epoch) you could do the following:
Then write the result using
worksheet_write_number()with an appropriate date format.@jeroen commented on GitHub (Aug 22, 2017):
Thanks!