?
Solved

Save an Excel Spreadsheet from vb.net

Posted on 2009-04-20
1
Medium Priority
?
484 Views
Last Modified: 2012-08-13
I have a vb.net 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
34D6A000
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.

Thanks

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
                Next
                '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
                    Next
                Next
                Dim dtmWorkDate As System.DateTime
 
                strFileName = "ExcelFile_" + fileNameUndex & ".xls"
 
                strFilePath = Application("PDF_Physical_FilePath")
                strExcelFile = strFilePath & strFileName
 
                .ActiveWorkbook().SaveAs(strExcelFile)

Open in new window

0
Comment
Question by:expertsexchangehunter
1 Comment
 
LVL 48

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 2000 total points
ID: 24192883
The file you are referring to is a temporary file created by Excel to ensure the file is saved properly -> http://support.microsoft.com/kb/814068

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

Wayne
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

609 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