Click here to Skip to main content
15,888,579 members

Comments by Member 11011853 (Top 5 by date)

Member 11011853 29-Nov-16 3:56am View    
Project has been implemented on VS2005, Doing enhancement on the project now. Trying to implement excel file generation in different ways, all method showing same error.
way-1:
Dim tmp As Integer = 1
Dim dc As DataColumn
For Each dc In dt.Columns
'Console.Write("{0,15}", dc.ColumnName)
Dim s As String = dc.ColumnName.ToString()
'tmp = tmp + 1
'worksheet.Cells(1, tmp).Value = dc.ColumnName.ToString()
worksheet1.Cells(1, tmp) = dc.ColumnName
tmp = tmp + 1
Next

way-2:
worksheet1.Cells(1, 1).value = "abc"
worksheet1.Cells(1, 2).value = "xyz"
worksheet1.Cells(1, 3).value = "pqrs"

way-3:
With worksheet1.Application
.Cells(1, 1).value = "PO Number"
.Cells(1, 2).value = "PONo"
.Cells(1, 3).value = "PO Date"

End With
Member 11011853 29-Nov-16 3:36am View    
The code that posted earlier is working fine in VS2010, but showing error in VS2005.
Member 11011853 29-Nov-16 3:28am View    
I tried to implement in other way, in that also getting same error.

Private Sub btnExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExport.Click
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object
Dim xlSheet_PI As Object

Dim xsht As Excel.Workbook

xlApp = CreateObject("Excel.Application")
Dim oldCI As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
xlApp.Workbooks.Add()
xlBook = xlApp.Workbooks.Add
xlSheet = xlBook.Worksheets(1)
'xlSheet_PI = xlBook.Worksheets(2)
xlSheet.Activate()


xlSheet.Name = "Material CheckList"
System.Threading.Thread.CurrentThread.CurrentCulture = oldCI



With xlSheet.Application
.Cells(1, 1).value = "ChkLstBarCodedetailId"
.Cells(1, 2).value = "ChkLstId"
.Cells(1, 3).value = "POId"
.Cells(1, 4).value = "OCId"
.Cells(1, 5).value = "PIId"
.Cells(1, 6).value = "ShipTo"
.Cells(1, 7).value = "TrayNo"
.Cells(1, 8).value = "ItemMasterId"
.Cells(1, 9).value = "ItemCode"
.Cells(1, 10).value = "BarCodeNo"
.Cells(1, 11).value = "ItemName"
.Cells(1, 12).value = "PackSize"
.Cells(1, 13).value = "LotNo"
.Cells(1, 14).value = "QtyOrdered"
.Cells(1, 15).value = "QtyInBin"
.Cells(1, 16).value = "DOC"
.Cells(1, 17).value = "UserName"
.Cells(1, 18).value = "PONumber"
.Cells(1, 19).value = "OCNumber"
.Cells(1, 20).value = "PINumber"
.Cells(1, 21).value = "ChkLstNo"
.Cells(1, 22).value = "Status"
End With

xlSheet.Application.visible = True

End Sub
Member 11011853 29-Nov-16 3:27am View    
Thanks for your reply. Before assigning value to cell,"temp" value has been incremented.
Member 11011853 3-Jun-15 4:25am View    
Hi...

GVemp.DataSource= ef.Select_EmpId(eid);
DataTable t = (DataTable)GVemp.DataSource;
txtAddress.Text = t.Rows[0]["Address"].ToString();
txtName.Text = t.Rows[0]["EmpName"].ToString();

i converted object type to datatable type in the above code, but i shows error as cant convert object type to datatable type...

Any help appreciated...!

thank u...!