from data textbox to excel vb.net -
I have this code that allows me to export the data contained in two The code has been tested and tested < / Strong> Your problem may be with something different which I can see. I provide some issues with the code I posted that I posted to you. Code below The way to release Excel objects TextBoxs in Excel The spreadsheet, the problem is that the excel file has not been created. The two statements have not worked to save the comments given below, maybe somebody can test it and tell me why this is wrong.
As a slow objExcel new Excel.Application exhibits an example of 'Excel Dim' as objWorkbook Excel.Workbook represents a workbook object dim objWorksheet as Excel.Worksheet 'A worksheet object represents objWorkbook = objExcel.Workbooks.Add objWorksheet = CTYPE (objWorkbook.Worksheets.Item (1), Excel.Worksheet)' This form includes two text box, cells A1 and A2 objWorksheet.Cells (1, 1) = TextBox1.Text objWorksheet.Cells (2, 1) = TextBox2.Text objWorkbook.Close (false) 'objWorkbook.Save ()' or 'about objWorkbook's values .SaveAs ("C: \ Temp \ Book1.xls "O) BjExcel.Quit ()
Dim xlApp as the new Excel. Request the Appeal xlWorkBook excel.Workbook dim xlWorkSheet as excel.Worksheet Try xlApp.DisplayAlerts = false xlWorkBook = xlApp.Workbooks.Add xlWorkSheet = DirectCast (xlWorkBook.Sheets ("Sheet1"), excel.Worksheet) xlApp.Visible = Do not show 'false'; We can and we do not even have xlWorkSheet.Cells (1, 1) = TextBox1.Text xlWorkSheet.Cells (2, 1) = TextBox2.Text xlWorkBook.SaveAs ("C: \ Temporary \ Book1.xls", fileformat : = 56) Save the workbook 'xlWorkBook.Close ()' release the workbook (xlApp.Quit) release all of our Excel objects we used to 'quit' ... ReleaseObject (xlWorkSheet) ReleaseObject (xlWorkBook) ReleaseObject (xlApp) pre-capture Try Exchange End
Public Shared Sub Release Try the object (object by object) as Runtime.InteropServices.Marshal.ReleaseComObject (obj) Exception as obj = nothing is Finally end of GC.Collect (try) End Sub
Comments
Post a Comment