Menu

xls File validation failure

wxsnail
2017-02-17
2023-10-27
<< < 1 2 (Page 2 of 2)
  • David Hoerl

    David Hoerl - 2017-03-25

    Sigh. Well I think I found something - but of course I cannot get my old version of Excel to complain. In the file workbook.cpp, at the bottom, there is a big if statement with references to WB_CONTINUE_REC. Comment that whole if statement out, and try again. This will almost for sure fix your problem. Why it wasn't flagged earlier is baffling. Obviously let me know what happens.

     
  • wxsnail

    wxsnail - 2017-03-28

    if there is 32832 records
    ALREADY=0 dataSize=8224 MAX=8224 dumpState=2. m_ContinueIndex=0

    if there is 32833 records
    ALREADY=0 dataSize=8228 MAX=8224 dumpState=2. m_ContinueIndex=0

    Comment the whole if statement out, doesn't fix any thing,
    and another warning from Excel says this file has some problem.

    //      if(m_pCurrentData != NULL) {
    //          // SST Table most likely record to exceed size, but its handled now in the record itself (breaks have to occur at defined places)
    //          // Should only happen with single cells having data > MAX_RECORD_SIZE. Have no idea if this works or not (DFH)
    //          if(!((CRecord*)m_pCurrentData)->AlreadyContinued() && ((CRecord*)m_pCurrentData)->GetRecordDataSize() > MAX_RECORD_SIZE && m_DumpState !=
    //             WB_CONTINUE_REC) {
    //              // Save the current dump state and change to the CONTINUE Record state
    //              CHANGE_DUMPSTATE(WB_CONTINUE_REC);
    //              //printf("ALREADY=%d dataSize=%lu MAX=%d (dumpState == CONTINUE) = %d\n", ((CRecord*)m_pCurrentData)->AlreadyContinued(), ((CRecord*)m_pCurrentData)->GetRecordDataSize(), MAX_RECORD_SIZE ,m_DumpState == WB_CONTINUE_REC);
    //
    //              m_ContinueIndex = 0;
    //
    //              repeat = true;
    //          }
    //      }
    
     
  • David Hoerl

    David Hoerl - 2017-03-28

    I took one of your older files/source - one with just one more row to cause your issue, and created one on my mac. I then "disassembled" them using libXls (which reads excel files). They both look identical. I did see this continue record appearing in files with the problem size, but not in the one that's just one row less.

    OK - another task for you. Create a file that has 32832 rows in it - start at 0 - and put the row number in it. Open that file in Excel, and add one more row at the bottom - to create the problematic size. Save it as an xls file. Send that to me along with the exact code you use. I will then disassemble that "good" file and see what Excel does differently than xlsLib.

    My old 2007 version of Excel running on an old Mac opens all of your files just fine.

     
  • wxsnail

    wxsnail - 2017-03-29

    I can open all my file with LibreOffice Calc base on Ubuntu without any warning, but Excel doesn't think so.

    Thresh_OK_32832.xls
    Code creat wtih 32832 rows, no warning

    Thresh_OK_32832+1byExcel.xls
    Add 1 row at the button of file by Excel, total rows 32833, no warning

    Thresh_Err_32833.xls
    Code creat wtih 32833 rows, Warning!

    exact code I use:

    #include <stdio.h>
    #include "xlslib/xlslib.h"
    
    using namespace std;
    using namespace xlslib_core;
    
    int main(int argc, char *argv[])
    {
       workbook wb;
       worksheet *sh = wb.sheet("Test1");
    
       unsigned int row_total = 32832;  //<=32832 is OK; >32832 will file validation failure
    
       for (unsigned int iRow = 0; iRow < row_total; iRow++) {
             sh->number(iRow, 0, 1.0);
       }
    
       wb.Dump("Thresh.xls");
       return (0);
    }
    
     
  • David Hoerl

    David Hoerl - 2017-03-31

    Excel adds so much new records to the file its almost impossible to read - but in any case it did not add any continue records - so the first commentting that I told you to do is in the right direction. I found this in sheetrec.cpp - its more code to deal with the CONTINUE record that probably isn't needed - try commenting it out too:

            if(payload > MAX_RECORD_SIZE) {
                size_t cont_overhead = ((payload + MAX_RECORD_SIZE - 1) / MAX_RECORD_SIZE); // continue payloads; account for trailing partial payloads: round up!
    
                rbsize.dbcell_size += (cont_overhead-1)*4;
            }
    

    Probably this one too:

         ret += dbcells + (MAX_ROWBLOCK_SIZE * MAX_COLUMNS_PER_ROW * RB_DBCELL_CELLSIZEOFFSET) / MAX_RECORD_SIZE; // worst-case: DBCELL+CONTINUEs for full-width rows**
    

    This was original code I got 10 years ago.

     
  • caifaraday

    caifaraday - 2023-10-27

    I meet the same problem. I comment the code suggested by David, but it did not fix the problem.

     
  • caifaraday

    caifaraday - 2023-10-27

    I build this lib with vs2010 on windows

     
<< < 1 2 (Page 2 of 2)

Log in to post a comment.