Domanda

I wrote the following program with xlsLib in order to create an Excel xls file with a worksheet with 100 000 rows:

#include <xlslib.h>
#include <xlslib/number.h>
#include <xlslib/common/xlstypes.h>

using namespace xlslib_core;
using namespace xlslib_strings;

int main()
{
    workbook wb;
    worksheet *sh = wb.sheet( "DATA" );

    unsigned32_t numberRows    = 100000;
    unsigned32_t numberColumns = 10;

    for(unsigned32_t r=0;r<numberRows;r++)
    {
        for(unsigned32_t c=0;c<numberColumns;c++)
        {
            double number = r + c;
            sh->number( r, c, number );
        }
    }
    wb.Dump("/tmp/test.xls");

    return 0;
}

When I open the file "test.xls" it appears that an integer overflow has ocurred: rows start to overlap since the value 65 535 that is the maximum value of a 16 unsigned integer. I don't know if I have made some mistake or the xlsLib has some bug. I really appreciate some help.

Thanks in advance.

È stato utile?

Soluzione

It's a limitation of Excel format. Excel 2003 and the earlier versions are limited to 65536 rows. So you can't create more rows if you use the old *.xls format. To create more rows you need to use the newer *.xlsx format but it looks like xlsLib doesn't support it.

More information: http://support.microsoft.com/kb/120596/en-us

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top