From FlexGrid to Excel


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: From FlexGrid to Excel

  1. #1
    Val Guest

    From FlexGrid to Excel


    Hi i wrote this function which populates Excel Sheet with values from FlexGrid.
    Problem it's too slow. It takes 40 seconds to place 400 records into Excel.
    I think its too slow well on my machine anyhow. Or is this acceptable time
    ? Here is the code if someone can modify it.
    For i = 0 To .Rows - 1
    Col = 1
    DoEvents
    For J = 0 To .Cols - 1
    xlSheet.Cells(m_Row, Col) = FlexGrid.TextMatrix(i, J)
    Col = Col + 1 'Increase Column Counter
    Next
    m_Row = m_Row + 1 'Increase Row Counter
    Next


  2. #2
    Paul Clement Guest

    Re: From FlexGrid to Excel

    On 18 Apr 2000 18:12:25 -0700, "Val" <Pushinks@aol.com> wrote:


    Hi i wrote this function which populates Excel Sheet with values from FlexGrid.
    Problem it's too slow. It takes 40 seconds to place 400 records into Excel.
    I think its too slow well on my machine anyhow. Or is this acceptable time
    ? Here is the code if someone can modify it.
    For i = 0 To .Rows - 1
    Col = 1
    DoEvents
    For J = 0 To .Cols - 1
    xlSheet.Cells(m_Row, Col) = FlexGrid.TextMatrix(i, J)
    Col = Col + 1 'Increase Column Counter
    Next
    m_Row = m_Row + 1 'Increase Row Counter
    Next

    Automation is terribly slow when exporting data to an Excel worksheet. I would definitely recommend
    using DAO or ADO and SQL to dump the data instead.


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

  3. #3
    Rob Bruce Guest

    Re: From FlexGrid to Excel

    Hi Val,

    Filling Excel sheets cell by cell is ponderously slow within Excel and
    unacceptably slow when using Excel as an out of process server. It helps to
    keep your cross-process calls to a minimum and to fill ranges in batches
    from variant arrays: Both can be achieved in this instance by filling an
    array during your loop and then using something like

    xlSheet.Range(xlSheet.Cells(1, 1), xlSheet.Cells(m_Row, Col),).Value =
    a_varMyArray

    HTH
    --
    Rob

    www.rb-ad.dircon.co.uk/rob/excelvba/

    Val <Pushinks@aol.com> wrote in message news:38fd07f9$1@news.devx.com...
    >
    > Hi i wrote this function which populates Excel Sheet with values from

    FlexGrid.
    > Problem it's too slow. It takes 40 seconds to place 400 records into

    Excel.
    > I think its too slow well on my machine anyhow. Or is this acceptable time
    > ? Here is the code if someone can modify it.
    > For i = 0 To .Rows - 1
    > Col = 1
    > DoEvents
    > For J = 0 To .Cols - 1
    > xlSheet.Cells(m_Row, Col) = FlexGrid.TextMatrix(i, J)
    > Col = Col + 1 'Increase Column Counter
    > Next
    > m_Row = m_Row + 1 'Increase Row Counter
    > Next
    >




  4. #4
    Val Guest

    Re: From FlexGrid to Excel


    Hi Rob. I yet don't know how Range works. but i'll give it a try. The last
    result i got in my app was to load 900 records in 21 seconds i think it's
    not bad. If i can do that faster with the variant array and then use Range
    i'll give it a shot. Just more explanation on this. I loop though the FlexGrid
    then fill the values into variant array. then where do i place it into the
    Cells ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center