2011-07-12 27 views

回答

4

LibreOffice使用ODF(開放文檔格式)。 ODF不是一種難以掌握的格式,因爲它基本上是將XML文件集合成一個文件,稱爲ODF文件。您可以通過read here瞭解如何讀取和保存ODF文件。此外,您還可以check here for a real example in C#

+0

因此,它是通常更容易操縱的.ods文件,只是有一個「轉換的.ods爲.xls」的情況下,在你的應用程序按鈕一些用戶需要它以.xls? – Karapapas

+0

@chris - 是的,無論哪個更容易。我相信Excel 2007和Excel 2010可以讀取打開的文檔文件,但我不確定。 – Icemanind

-1

如果已安裝的LibreOffice尋找cli_basetypes.dll,cli_cppuhelper.dll,cli_oootypes.dll,cli_uno.dll,cli_ure.dll,cli_uretypes.dll然後添加引用到您的項目,它必須努力您還安裝了「用於Word,Excel和PowerPoint文件格式的Microsoft Office兼容包」和「Microsoft Access數據庫引擎2010可再發行組件」(無需完整的Office安裝即可獲取ACE.OLEDB.12.O連接)。這是VB Sample的一部分,其中我連接到oledb以創建一些查詢。

OpenFileDialog.Filter = "Spreadsheets (*.xls*)|*.xls*" 
    OpenFileDialog.Multiselect = False 
    Try 
     If (OpenFileDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then 
      objOffice = CreateObject("com.sun.star.ServiceManager") 'preparar instancia libreOffice (prepare libreOffice instance) 
      instOffice = objOffice.createInstance("com.sun.star.frame.Desktop") 
      Dim obj(-1) As Object 
      Dim myDoc = instOffice.loadComponentFromURL("file:///" & OpenFileDialog.FileName.Replace("\", "/"), "_default", 0, obj) 
      Dim hojas = myDoc.getSheets().getElementNames() 'Obtener nombres de las hojas de calculo (get Spreadsheet names) 
      System.Threading.Thread.Sleep(1000) 'Esperar a que termine la instancia Office (await libreOffice thread) 
      myDoc.Close(True) 

      Dim MyConnection As System.Data.OleDb.OleDbConnection 'Preparar conexión para realizar consulta tipo sql (preparing connection) 
      Dim DtSet As System.Data.DataSet 
      Dim MyCommand As System.Data.OleDb.OleDbDataAdapter 

      If OpenFileDialog.FileName.ToUpper.Contains(".XLSX") Then 
       MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & OpenFileDialog.FileName & "';Extended Properties='Excel 12.0 Xml;HDR=YES;IMEX=1;'") 
      Else 
       MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & OpenFileDialog.FileName & "';Extended Properties='Excel 12.0;HDR=YES;IMEX=1'") 
      End If 
相關問題