none
convert xml to excel problem RRS feed

  • Pertanyaan

  • para suhu sekalian, saya ada masalah konversi xml ke excel pada aplikasi yg saya buat,

    muncul error seperti ini:

    Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))

    code visual basic yg saya gunakan seperti ini:

    Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
        OpenFileDialog1.Filter = "logfile(*.log)|*.log"
        OpenFileDialog1.ShowDialog()
        Dim xlApp As Excel.Application
        Dim xlWorkBook As Excel.Workbook
        Dim xlWorkSheet As Excel.Worksheet
        Dim misValue As Object = System.Reflection.Missing.Value
    
        Dim ds As New DataSet
        Dim xmlFile As XmlReader
        Dim i, j As Integer
    
        xlApp = New Excel.ApplicationClass
        xlWorkBook = xlApp.Workbooks.Add(misValue)
        xlWorkSheet = xlWorkBook.Sheets("sheet1")
    
        xmlFile = XmlReader.Create(OpenFileDialog1.FileName, New XmlReaderSettings())
        ds.ReadXml(xmlFile)
    
        For i = 0 To ds.Tables(0).Rows.Count - 1
          For j = 0 To ds.Tables(0).Columns.Count - 1
            xlWorkSheet.Cells(i + 1, j + 1) = _
            ds.Tables(0).Rows(i).Item(j)
          Next
        Next
    
        Me.SaveFileDialog2.Filter = "xlsx(*.xlsx)|*.xlsx"
        SaveFileDialog2.ShowDialog()
        'plot = SaveFileDialog2.FileName
    
        xlWorkSheet.SaveAs(SaveFileDialog2.FileName)
        xlWorkBook.Close()
        xlApp.Quit()
    
        releaseObject(xlApp)
        releaseObject(xlWorkBook)
        releaseObject(xlWorkSheet)
      End Sub
    
      Private Sub releaseObject(ByVal obj As Object)
        Try
          System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
          obj = Nothing
        Catch ex As Exception
          obj = Nothing
        Finally
          GC.Collect()
        End Try
      End Sub
    

    xml file yg saya gunakan seperti dibawah ini:

    <?xml version="1.0" encoding="utf-8"?>
    <parameters>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>18</Rscp>
      <Ecno>101</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>23</Rscp>
      <Ecno>100</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>22</Rscp>
      <Ecno>100</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>21</Rscp>
      <Ecno>99</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>21</Rscp>
      <Ecno>99</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>20</Rscp>
      <Ecno>101</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>19</Rscp>
      <Ecno>100</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>24</Rscp>
      <Ecno>101</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>20</Rscp>
      <Ecno>101</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>23</Rscp>
      <Ecno>100</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>24</Rscp>
      <Ecno>101</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>19</Rscp>
      <Ecno>100</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>22</Rscp>
      <Ecno>100</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>19</Rscp>
      <Ecno>98</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>22</Rscp>
      <Ecno>100</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>25</Rscp>
      <Ecno>101</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>23</Rscp>
      <Ecno>100</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>24</Rscp>
      <Ecno>102</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>22</Rscp>
      <Ecno>100</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>24</Rscp>
      <Ecno>101</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>22</Rscp>
      <Ecno>101</Ecno>
     </params>
     <params>
      <Type>
    ActiveSet</Type>
      <Scramblingcode>33(REF)</Scramblingcode>
      <Rscp>24</Rscp>
      <Ecno>101</Ecno>
     </params>
    </parameters>
    


    mohon pencerahannya para suhu sekalian..

    terima kasih

    Minggu, 03 Juli 2011 08.47

Jawaban