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 7009147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:49:33+00:00 2026-05-27T21:49:33+00:00

We have an automatic process that opens a template excel file, writes rows of

  • 0

We have an automatic process that opens a template excel file, writes rows of data, and returns the file to the user. This process is usually fast, however I was recently asked to add a summary page with some Excel formulas to one of the templates, and now the process takes forever.

It successfully runs with about 5 records after a few minutes, however this week’s record set is almost 400 rows and the longest I’ve let it run is about half an hour before cancelling it. Without the formulas, it only takes a few seconds to run.

Is there any known issues with writing rows to an Excel file that contains formulas? Or is there a way to tell Excel not to evaluate formulas until the file is opened by a user?

The formulas on the summary Sheet are these:

' Returns count of cells in column where data = Y
=COUNTIF(Sheet1!J15:Sheet1!J10000, "Y") 
=COUNTIF(Sheet1!F15:Sheet1!F10000, "Y")

' Return sum of column where data is a number greater than 0
' Column contains formula calculating the difference in months between two dates
=SUMIF(Sheet1!I15:Sheet1!I10000,">0",Sheet1!I15:Sheet1!I10000)  

' Returns a count of distinct values in a column
=SUMPRODUCT((Sheet1!D15:Sheet1!D10000<>"")/COUNTIF(Sheet1!D15:Sheet1!D10000,Sheet1!D15:Sheet1!D10000&""))

And the code that writes to excel looks something like this:

Dim xls as New Excel.Application()
Dim xlsBooks as Excel.Workbooks, xlsBook as Excel.Workbook
Dim xlsSheets as Excel.Sheets, xlsSheet as Excel.Worksheet
Dim xlsCells as Excel.Range

xls.Visible = False
xls.DisplayAlerts = False

xlsBooks = xls.Workbooks

xlsBooks.Open(templateFile)
xlsBook = xlsBooks.Item(1)  

' Loop through excel Sheets. Some templates have multiple sheets.
For Each drSheet as DataRow in dtSheets.Rows
    xlsSheets = xlsBook.Worksheets
    xlsSheet = CType(xlsSheets.Item(drSheet("SheetName")), Excel.Worksheet)
    xlsCells = xlsSheet.Cells

    ' Loop though Column list from Database. Each Template requires different columns
    For Each drDataCols as DataRow in dtDataCols.Rows

        ' Loop though Rows to get data
        For Each drData as DataRow in dtData.Rows
            xlsCells(drSheet("StartRow") + dtData.Rows.IndexOf(drData), drDataCols("DataColumn")) = drData("Col" + drDataCols("DataColumn").toString).toString
        Next
    Next
Next

xlsSheet.SaveAs(newFile)
xlsBook.Close
xls.Quit()
  • 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-27T21:49:34+00:00Added an answer on May 27, 2026 at 9:49 pm

    With auto mode calculation, recalculation occurs after every data input/changed. I had the same problem, was solved by setting Manual calculation mode. (Reference MSDN link.)

    xls.Calculation = Excel.XlCalculation.xlCalculationManual
    

    Also, this property can only be set after a Workbook has been opened or it will throw a run-time error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have prior experience in build a automatic build process for .NET & Delphi
I have written the batch file below, in order to automate the process of
Is there a way in rst to have automatic header numbering ? That is
We have an automatic reporting and notification system written in .net that sends emails
I have this piece of code for reading from an excel cell: public T
I have a testing script that needs to open a process (a Pyro server),
I have a repeatable business process that I execute every week as part of
I have a php program that needs a file that exists in a certain
I have a (many) .dgp files, which is an image file that I can't
I have a complete automatic notification system running on my web page, that is

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.