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

No warning raised when there are more than 255 data series within a chart #399

Closed
roolebo opened this Issue Dec 12, 2016 · 2 comments

Comments

2 participants
@roolebo

roolebo commented Dec 12, 2016

Excel doesn't recognize charts if they have more than 255 data series. This is documented limit. Excel doesn't allow to create a chart from a data region with 256 or more columns, it prints "The Maximum number of data series per chart is 255" when a user attempt to select such region.

One can easily hit the limit when a chart is created programmatically:

import xlsxwriter                                
                                                 
workbook = xlsxwriter.Workbook('malformed.xlsx') 
worksheet = workbook.add_worksheet()             
                                                 
worksheet.write(0, 0, 'name')                    
worksheet.write(1, 0, 'value')                   
                                                 
chart = workbook.add_chart({'type': 'column'})   
for i in range(1, 257):                          
    worksheet.write(0, i, 'name{}'.format(i))    
    worksheet.write(1, i, i)                     
    chart.add_series({                           
        'name': 'name{}'.format(i),              
        'values': [worksheet.name, 1, i, 1, i]   
    })                                           
                                                 
worksheet.insert_chart(2, 0, chart)              
                                                 
workbook.close()                                 

When I try to open malformed.xlsx in Excel 2016, it proposes to repair the document and drops the chart if I confirm. LibreOffice can open the document. So I think the document is valid from Office Open XML perspective.

I'm using python 2.7.12 and XlsxWriter 0.9.4.

XlsxWriter should raise a warning or even exception (in the next major version) if Excel hard limits are hit.

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Dec 12, 2016

Owner

Hi Roman,

Thanks for the report. I'll fix it in the next release.

Regards,

John

Owner

jmcnamara commented Dec 12, 2016

Hi Roman,

Thanks for the report. I'll fix it in the next release.

Regards,

John

@jmcnamara jmcnamara self-assigned this Dec 12, 2016

jmcnamara added a commit that referenced this issue Dec 26, 2016

Limit the number of chart series to 255.
Excel has a limit of 255 series per chart.

Issue #399.
@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Dec 26, 2016

Owner

Fixed in version 0.9.6.

Owner

jmcnamara commented Dec 26, 2016

Fixed in version 0.9.6.

@jmcnamara jmcnamara closed this Dec 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment