How to embed the Excel file in VB.NET 2005 Resources

G

Guest

Hi all,

Does anyone know how to embed the Excel file in VB.NET 2005 Resources?

Here is what I am doing at the moment:
1) In my VB.NET 2005 project code I load the excel with it path into string
as:
------------------------------------------------------------------------------------------------
Dim fileNameXL As String = "_MYEXCEL_REPORTS.XLS"
Dim pathNameXL As String = "\EXCEL_TEMP\"
Dim fullPathXL As String
fullPathXL = Path.GetFullPath(System.Windows.Forms.Application.StartupPath &
"\..")
fullPathXL = fullPathXL & pathNameXL
myExcelLocation = fullPathXL & fileNameXL
------------------------------------------------------------------------------------------------




2) Then I open the my excel file as:
------------------------------------------------------------------------------------------------
oWB = oXL.Workbooks.Open(FileName:=myExcelLocation, UpdateLinks:=False,
ReadOnly:=False)
------------------------------------------------------------------------------------------------


3) After analysing my data I simply insert into DataTable and run the data
table to created string file then I copy the string file into my
pre-formatted excel file as:
------------------------------------------------------------------------------------------------
With oSheet.Range("A6")
.Select()
.PasteSpecial(Excel.XlPasteType.xlPasteAll)
End With
------------------------------------------------------------------------------------------------



4) And save my excel file in different name under the C drive as:
------------------------------------------------------------------------------------------------
FileName = FolderName & "\" & FolderDate & "_YKY_RISK_REPORT.XLS"
oWB.SaveAs(FileName)
------------------------------------------------------------------------------------------------


Now instead of loading my pre-formated "_MYEXCEL_REPORTS.XLS" file everytime
I run the application I want to save this file into my application resources
so I can open from there do mu job and save it into user C dreive.

Why do I need this?
First reason is that user cannot delete accidentaly the _MYEXCEL_REPORTS.XLS
file
or nor they can cahange the format of the my excel file.

The reason I didn't wnat to create Excel file from scratch is to save time
because daily I will have to make 2-3 small application regading for the
reports and each application runs only upto 3 to 6 months. then when bussines
logic is chanage so the report layout will chanage plus we have more than 50
user that can use this app to generate report for different customer in daily
basis.

So I thought with VB.NET 2005 I can create a Excel file that I will deaisgn
the layout quickly the I can embed into my VB.NET 2005 application resources
quickly get the data from AS400 analysed it and open this excel file that is
in resources past the values and write into C drive as excel file but under
different name.

Does anyone knows any good article or example project so I can save much
more time and secure my application?

Thank you for reading my post.

Rgds,
GC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top