Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3853588
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:29:33+00:00 2026-05-19T17:29:33+00:00

I’ve inherited a large project which uses Office.Interop.Excel to insert data into a spreadsheet.

  • 0

I’ve inherited a large project which uses Office.Interop.Excel to insert data into a spreadsheet.

In terms visible interaction, you click on a button and an Excel spreadsheet appears, with all the data already inserted. I mention this because I’ve seen it done elsewhere with the program already being open and values being inserted. The program I am working with inserts the data before Excel appears.

Unfortunately, once a relatively large amount of data is being inserted, the information transfer to Excel locks up and the program cannot continue.

Anyway, I did some investigating and found the following line:

myWorksheet.Range("A" & rowNumber).Resize(dataArray.GetUpperBound(0) + 1, columnCount).Value = dataArray

This copies all of the data in dataArray directly onto a bunch of cells in the worksheet.

I guessed that the problem might be caused by attempting to transfer such a large amount of data at once, so I altered it to copy data over row-by-row:

For horizIndex As Integer = 0 To dataArray.GetUpperBound(0)
    Dim subArr(0, arr.GetUpperBound(1)) As Object
    For columnIndex As Integer = 0 To dataArray.GetUpperBound(1)
        subArr(0, columnIndex) = dataArray(horizIndex, columnIndex)
    Next
    myWorksheet.Range("A" & (rowNumber + horizIndex)).Resize(horizIndex + 1, columnCount).Value = arr
Next

This will copy 350 or so rows to Excel and then the line setting Value simply stops returning.

Can anyone suggest a way around this?

EDIT: Okay, I’ve tried a bunch of what Lazarus suggested below, and here’s where I am right now:

So long as the data is relatively short, or the datatypes are fairly simple (Integers, etc.) all variations of the code work fine. The original mass-copy works fine, the copy-by-line works and the copy-by-cell works, so long as the dataset is either small or simple.

My actual dataset, though, is relatively complex, and contains several datatypes, including Strings.

It falls over after 350-ish rows. It falls over on the Excel side of the code, the thread goes away to Excel and never comes back.

So, any more ideas, anyone?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:29:33+00:00Added an answer on May 19, 2026 at 5:29 pm

    I think the problem here is with your ever expanding cell range.

    I’d rework the line:

    myWorksheet.Range("A" & (rowNumber + horizIndex)).Resize(horizIndex + 1, columnCount).Value = arr
    

    to read

    myWorksheet.Range("A" & (rowNumber + horizIndex)).Resize(1, columnCount).Value = subArr
    

    EDIT

    Given that you are effectively iterating over every cell why not take advantage of that:

    For horizIndex As Integer = 0 To dataArray.GetUpperBound(0)
        For columnIndex As Integer = 0 To dataArray.GetUpperBound(1)
            myWorksheet.Cells(horizIndex + 1, columnIndex + 1).Value = dataArray(horizIndex, columnIndex)
        Next
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.