Save an Excel Spreadsheet from

Posted on 2009-04-20
Last Modified: 2012-08-13
I have a web app that creates  an Excel spreadsheet. I need to save the spreadsheet then open and display the spreadsheet and delete the file.
I have already coded everyhining but the save, open and display and delete.
The problem with this is besides creating the file it also creates a file like
that contains the spreadsheet also. This is niot wanted becasse when I want to delete the spreadsheet I won't know the files name to delete.
I need the missing code.


With myExcel

                .SheetsInNewWorkbook = 1

                myExcelWB = .Workbooks.Add()

                myExcelWS = myExcelWB.Worksheets(1)

                'TO Display the column name in the the excel file.   

                For intColumn = 0 To ds.Tables(0).Columns.Count - 1

                    myExcelWS.Cells(1, intColumn + 1).Value = ds.Tables(0).Columns(intColumn).ColumnName.ToString


                'For displaying the column value row-by-row in the the excel file.         

                For intRow = 0 To ds.Tables(0).Rows.Count - 1

                    For intColumnValue = 0 To ds.Tables(0).Columns.Count - 1

                        myExcelWS.Cells(intRow + 2, intColumnValue + 1).Value = ds.Tables(0).Rows(intRow).ItemArray(intColumnValue).ToString

                        '                        myExcelWS.Cells(intRow + 1, intColumnValue + 1).Value = ds.Tables(0).Rows(intRow).ItemArray(intColumnValue).ToString



                Dim dtmWorkDate As System.DateTime

                strFileName = "ExcelFile_" + fileNameUndex & ".xls"

                strFilePath = Application("PDF_Physical_FilePath")

                strExcelFile = strFilePath & strFileName


Open in new window

Question by:expertsexchangehunter
    1 Comment
    LVL 46

    Accepted Solution

    The file you are referring to is a temporary file created by Excel to ensure the file is saved properly ->

    It should be deleted when you properly quit the Excel application.


    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
    MS Access 2003 or later To MySQL Migration Project Hello All, this is my second article in the category of MS-OFFICE Automation. In internet I am not able to find any comprehensive resource on the Migration of MS Access back-end to MySQL so I fin…
    The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
    This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now