Hi,
I wrote the below code to export data from excel to xml, but in excel file if column cell is empty then in xml that column/element is not showing.
i want whereever empty cell in xml should show as 0
- Private Function exportExceltoXML(ByVal excelPath As String) As String
- Dim cnExcel As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excelPath + ";Extended Properties=Excel 12.0;")
- cnExcel.Open()
- Dim ds As New DataSet
- Dim da As New OleDbDataAdapter("SELECT * FROM [Sheet1$]", cnExcel)
- da.Fill(ds)
- cnExcel.Close()
- Dim sXML As String
- sXML = ds.GetXml()
- ds.WriteXml(TextBox1.Text & "\Trn_Daily3.xml")
- ds.Dispose()
- da.Dispose()
- MsgBox("Exported successfully")
- Return sXML
- End Function
Thanks
Basit.

Sagar Pandurang KapRank #606 · 4K reputationPosted Jan 29, 2018, 9:33 PM EST
Basit KhanRank #4,768 · 326 reputationPosted Jan 29, 2018, 9:56 PM EST
Suraj KumarRank #353 · 7.1K reputationPosted Jan 29, 2018, 10:08 PM EST
alice yangRank #2,329 · 607 reputationPosted Jan 30, 2018, 2:37 PM EST