in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

C1Excel.Load()

Last post 05-16-2008 11:46 AM by vantibus. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-16-2008 9:09 AM

    C1Excel.Load()

    Is there a method of using Load() where I can have some control over the load process.  Calling Load() against large files (about 5000 rows) stored on a network share appears to hang the application while loading the rows into memory.  I'd like to be able to provide user feedback via a progress bar during the load from disk as I do when processing the 5000 rows after they have been loaded.

    In a nutshell, an ERP system is exporting Open Orders to an Excel spreadsheet on a daily basis.  The file is stored on a network drive.  My app reads this Excel file every morning and imports the data into a database table.  Reading (loading), massaging, and storing the Excel data into the database takes about 6 minutes.  I do show a progress bar for the process, but there is a huge 30 - 60 second delay (never actually put a stop watch to it) between the time the user clicks the Import button and the time the progress bar takes off -- because the progress bar doesn't start until after Load(), which takes forever across the network.

    My customer and I don't really care about the load time itself, it's the lack of user feedback during the load time that's the problem.
     

  • 05-16-2008 11:46 AM In reply to

    Re: C1Excel.Load()

    Why does this

                         //Load the Excel data
                        FileStream fs = new FileStream(edtFileName.Text, FileMode.Open,
                            FileAccess.Read);
                        int iLength = (int)fs.Length;
                        MemoryStream ms = new MemoryStream(iLength);
                        int iBytesToRead = 1024;
                        int iBytesRead = 0;
                        int iOffset = 0;
                        //do
                        //{
                        //  iBytesRead = fs.Read(ms.GetBuffer(), iOffset, iBytesToRead);
                        //  iOffset += iBytesRead;
                        //} while (iBytesRead > 0 && iOffset < iLength);
                        fs.Read(ms.GetBuffer(), iOffset, iLength); //this replaces the do-while loop (both yield same result)
                        c1XLBook.Load(ms, true); //<<<<-------- blows up here
     

    result in this error?

    "System.IO.IOException was unhandled by user code
      Message="Failed to open storage file."
      Source="C1.C1Excel.2"
      StackTrace:
           at C1.C1Excel.a0.b(Stream A_0)
           at C1.C1Excel.C1XLBook.c(Stream A_0, Boolean A_1)
           at C1.C1Excel.C1XLBook.Load(Stream stream, FileFormat format, Boolean fillSheets)
           at C1.C1Excel.C1XLBook.Load(Stream stream, Boolean fillSheets)
           at Tenneco.frmImportData.btnImport_Click(Object sender, EventArgs e)

     

    My goal was to read the file into memory a chuck at a time and provide feedback during the read -- under the assumption that C1Excel.Load() would be quick since the data is in memory not in a file out on a network share.  My assumption is based on the fact that Load() takes no time at all on my laptop where everything is run from the local hard drive.

    Now that I've written this, I suppose I can try transferring the file from the network to the local hard drive... and then Load() the local copy.

     
    What a pain.
     


Page 1 of 1 (2 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.