Question

I have generated a spreadsheet using XlsxWriter 0.5.3. The category cells are created using write_datetime() and appear correctly but I have two problems: 1. I want the X axis to be scaled by date instead of my entry so the timescale can be seen. 2. The X axis entries show the number of days instead of a formatted date.

The first can be done by manually changing te X axis format from 'Automatic' or 'Text' to date - is there a way to do it using XlsxWriter or isn't it supported? The second is a problem because it becomes difficult for someone looking at the chart to go to the correct results. I have tried various solutions and it seems that a cell written using write_timedate() returns the nubmer of days only.

date_time = datetime.datetime.strptime(date_str, '%Y/%m/%d')
worksheet.write_datetime(row_idx, col_idx, date_time, self.formats['Borders date'])

Thanks.

Was it helpful?

Solution

For the first part of your question you can set the 'date_axis': True option in set_x_axis().

See this Date Axis Chart example from the docs.


(source: readthedocs.org)

That should also resolve your second question. If not post a separate question using the above chart example as the sample code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top