I am using visual studio express 2012,
i have created a Vb calculation application (outputs based on variable inputs) & i need to save these input and output data to excel file each time i click save.
More Details
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim xls As Microsoft.Office.Interop.Excel.Application
Dim xlsWorkBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlsWorkSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
xls = New Microsoft.Office.Interop.Excel.Application
xlsWorkBook = xls.Workbooks.Open("D:\bookl.xlsx")
xlsWorkSheet = xlsWorkBook.Sheets("sheet1")
xlsWorkSheet.Cells(1, 1) = TextBox1.Text
xlsWorkBook.Close()
xls.Quit()
End Sub
my problem here is that in every time i click the save button it saves the data to a excel sheet file which i have to specify its path previously.
What i wish to do is if there is any way to load from VB it self then choose where to save it (because iam going to use it in a lot of machines, so i don't want to put the excel file in the same path each time i use the application in any other machine)
Loading
barcode addictPosted May 4, 2014, 3:57 AM
http://stackoverflow.com/questions/21020359/export-data-from-vb-to-excel-sheet
Garry GibsonPosted Apr 24, 2014, 6:54 AM
Dim xlsWorkBook As ExcelFile = ExcelFile.Load("bookl.xlsx")
Dim xlsWorkSheet As ExcelWorksheet = xlsWorkBook.Worksheets("sheet1")
xlsWorkSheet.Cells(0, 0) = TextBox1.Text
xlsWorkBook.Save("bookl.xlsx")
You can specify file path for both Load and Save methods by providing an absolute path or a path relative to the applications execution file path.
amado firstPosted Jan 9, 2014, 4:44 AM
Anubhav ChaudharyPosted Jan 9, 2014, 1:09 AM
I think you should try it from here:
http://www.dotnetcurry.com/showarticle.aspx?ID=144
You can also try my these Articles:
http://www.c-sharpcorner.com/UploadFile/cd7c2e/export-sql-data-to-excel-using-Asp-Net/
http://www.c-sharpcorner.com/UploadFile/cd7c2e/delete-a-file-on-certain-attempts-by-invalid-user/
amado firstPosted Jan 8, 2014, 5:01 PM
LaxmikantPosted Jan 8, 2014, 4:47 PM
For more info you can see
http://dotnetmentors.com/c-sharp/how-to-export-sql-data-to-excel-using-microsoft-office-interop.aspx