顯示具有 LibreOffice 標籤的文章。 顯示所有文章
顯示具有 LibreOffice 標籤的文章。 顯示所有文章

2026年5月26日 星期二

[研究]LibreOffice 對 .odt 有類似 MS Word 的編修模式可用 ?

[研究]LibreOffice 對 .odt 有類似 MS Word 的編修模式可用 ?

2026-05-26

LibreOffice 對 .odt 有類似 MS Word 的編修模式可用 ?

*****

有。LibreOffice Writer 對 .odt 原生支援「追蹤修訂/編修模式」(Track Changes),功能類似 Microsoft Word 的「追蹤修訂」。

常用功能:

  • 開啟編修模式:編輯(Edit) → 追蹤修訂(Track Changes) → 記錄(Record)
  • 顯示修訂痕跡:編輯 → 追蹤修訂 → 顯示(Show)
  • 接受/拒絕修訂:編輯 → 追蹤修訂 → 管理(Manage),可逐筆接受、拒絕、查看作者與時間。
  • 支援內容
    • 文字新增/刪除
    • 格式變更
    • 表格修改
    • 註解(Comment)


而且 .odt 是 OASIS OpenDocument 格式的原生格式,因此:

  • LibreOffice + .odt
  • Apache OpenOffice + .odt

通常比 Word 開 .odt 時的相容性更完整。

你前面遇到的情況:Word 開 .odt,存檔後「編修模式」關掉、修訂消失

這是因為 Word 對 ODT 的追蹤修訂支援不完整。Word 的追蹤修訂主要是針對 .docx 設計;開放/儲存 .odt 時,部分修訂資訊可能無法完整保存。

因此若需要:

  • 長期使用 .odt
  • 保留完整修訂紀錄
  • 多人協作編修

比較建議:

  • 使用 LibreOffice Writer 編輯 .odt
  • 或改用 .docx 搭配 Word。

(完)

2024年10月29日 星期二

[研究]ODF 1.4 (Open Document Format 1.4) 草案現況

[研究]ODF 1.4 (Open Document Format 1.4) 草案現況

2024-10-29

OpenDocument standardization
https://en.wikipedia.org/wiki/OpenDocument_standardization#OpenDocument_1.4

OASIS
https://en.wikipedia.org/wiki/OASIS_(organization)

OpenDocument
https://en.wikipedia.org/wiki/OpenDocument

  • Microsoft Office 2007 (with Service Pack 2 or 3) supports ODF 1.1[45] (Windows only)
  • Microsoft Office 2010 supports ODF 1.1 (Windows only)
  • Microsoft Office 2013 supports ODF 1.2 (Windows only)
  • Microsoft Office 2016 and 2019 support ODF 1.2 (Windows: read/write; OS X: read-only after online conversion[46])
  • Microsoft Office 2021 supports ODF 1.3[47] (Windows and MacOS)


Microsoft 365 apps now support OpenDocument Format 1.4
https://techcommunity.microsoft.com/t5/microsoft-365-insider-blog/microsoft-365-apps-now-support-opendocument-format-1-4/ba-p/4226735
Office 365 支援 ODF 1.4

What's new in Word 2024 for Windows and Mac
https://support.microsoft.com/en-us/office/what-s-new-in-word-2024-for-windows-and-mac-9fe36ecd-820b-4f42-a9a2-0861f7615954
Office 2024 支援 ODF 1.4

[MS-OODF14]: Office Implementation Information for ODF 1.4 Standards Support
https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oodf14/ad5a09c6-609d-47b3-bc56-7ab49a8d4f35

[ODF1.4] OASIS, "Open Document Format for Office Applications (OpenDocument) Version 1.4", https://go.microsoft.com/fwlink/?linkid=2255466

ODF GitHub
https://github.com/oasis-tcs/odf-tc/tree/master/docs
https://docs.oasis-open.org/office/OpenDocument/v1.4/csd01/

  • 2024-03-18
  • Updating CSD-01 from WD-03
  • CSD-01(Committee Specification Draft 01): 進入了更正式的標準化過程
  • WD-03(Working Draft 03)

ODF Specification Tooling
https://github.com/oasis-tcs/odf-tc

(待續)

[研究]ASP.NET,WebForm,免ODS套件寫入匯出.ods

[研究]ASP.NET,WebForm,免ODS套件寫入匯出.ods

2024-10-29

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default2.aspx.cs" 
    Inherits="WebApplication1.Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">

    </form>
</body>
</html>



Default.aspx.cs

using System;
using System.IO;
using System.IO.Compression;

namespace WebApplication1
{
    public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GenerateOdsFile();
        }
        private void GenerateOdsFile()
        {
            using (MemoryStream odsStream = new MemoryStream())
            {
                using (ZipArchive zip = new ZipArchive(odsStream, ZipArchiveMode.Create, true))
                {
                    // 添加 mimetype 檔案
                    ZipArchiveEntry mimeEntry = zip.CreateEntry("mimetype", CompressionLevel.NoCompression);
                    using (StreamWriter writer = new StreamWriter(mimeEntry.Open()))
                    {
                        writer.Write("application/vnd.oasis.opendocument.spreadsheet");
                    }

                    // 添加必要的 META-INF/manifest.xml 文件
                    ZipArchiveEntry manifestEntry = zip.CreateEntry("META-INF/manifest.xml", CompressionLevel.Fastest);
                    using (StreamWriter writer = new StreamWriter(manifestEntry.Open()))
                    {
                        writer.Write(
                            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                            "<manifest:manifest xmlns:manifest=\"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0\">\n" +
                            "  <manifest:file-entry manifest:full-path=\"/\" manifest:media-type=\"application/vnd.oasis.opendocument.spreadsheet\"/>\n" +
                            "  <manifest:file-entry manifest:full-path=\"content.xml\" manifest:media-type=\"text/xml\"/>\n" +
                            "</manifest:manifest>"
                        );
                    }

                    // 添加 content.xml 文件
                    ZipArchiveEntry contentEntry = zip.CreateEntry("content.xml", CompressionLevel.Fastest);
                    using (StreamWriter writer = new StreamWriter(contentEntry.Open()))
                    {
                        writer.Write(
                            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                            "<office:document-content xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\" " +
                            "xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\" " +
                            "xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\" " +
                            "xmlns:style=\"urn:oasis:names:tc:opendocument:xmlns:style:1.0\" " +
                            "office:version=\"1.2\">\n" +
                            "<office:body><office:spreadsheet><table:table table:name=\"Sheet1\" table:style-name=\"ta1\">\n" +
                            "<table:table-column table:style-name=\"co1\" table:number-columns-repeated=\"2\"/>\n" +
                            "<table:table-row table:style-name=\"ro1\"><table:table-cell><text:p>資料1</text:p></table:table-cell>" +
                            "<table:table-cell><text:p>資料2</text:p></table:table-cell></table:table-row>\n" +
                            "<table:table-row table:style-name=\"ro1\"><table:table-cell><text:p>資料3</text:p></table:table-cell>" +
                            "<table:table-cell><text:p>資料4</text:p></table:table-cell></table:table-row>\n" +
                            "</table:table></office:spreadsheet></office:body></office:document-content>"
                        );
                    }
                }

                odsStream.Position = 0;
                Response.Clear();
                Response.ContentType = "application/vnd.oasis.opendocument.spreadsheet";
                Response.AddHeader("Content-Disposition", "attachment; filename=sample.ods");
                odsStream.CopyTo(Response.OutputStream);
                Response.Flush();
                Response.End();
            }
        }
        //---
    }
}







結果 LibreOffice 7.6 正常讀取,但 Excel 2021開啟有警告,修復後正常顯示。這是因為Excel 對 .ods 文件有較嚴格的要求,尤其是 XML 標籤和屬性的結構。敝人嘗試多次,暫時仍無法解決,或許可以一開始用 LibreOffice建立一個正常的 template.ods 給程式插入資料使用。

Default.aspx.cs

using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Xml.Linq;

namespace WebApplication1
{
    public partial class Default3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string odsFilePath = @"C:\Users\Administrator\Downloads\Template2.ods";
            string targetOdsPath = @"C:\Users\Administrator\Downloads\S2.ods";
            File.Copy(odsFilePath, targetOdsPath, overwrite: true);
            InsertDataToODS(targetOdsPath);
        }
        public void InsertDataToODS(string odsFilePath)
        {
            // 定義要插入的資料
            var data = new string[,]
            {
                { "A1", "B1" },
                { "A2", "B2" }
            };

            // 打開 .ods 檔案 (實際上是 Zip 檔案)
            using (var zip = ZipFile.Open(odsFilePath, ZipArchiveMode.Update))
            {
                // 尋找 content.xml
                var entry = zip.GetEntry("content.xml");
                if (entry == null)
                {
                    throw new FileNotFoundException("content.xml not found in the .ods file.");
                }

                // 讀取 content.xml 並載入 XML 文件
                XDocument doc;
                using (var stream = entry.Open())
                {
                    doc = XDocument.Load(stream);
                }

                // 尋找要插入資料的表格位置 (這裡假設是 Sheet1)
                XNamespace ns = "urn:oasis:names:tc:opendocument:xmlns:table:1.0";
                var sheet = doc.Descendants(ns + "table").FirstOrDefault();

                if (sheet != null)
                {
                    // 生成 2x2 表格的 Row 和 Cell
                    for (int i = 0; i < 2; i++)
                    {
                        var row = new XElement(ns + "table-row");
                        for (int j = 0; j < 2; j++)
                        {
                            var cell = new XElement(ns + "table-cell",
                                new XElement(ns + "p", data[i, j]));
                            row.Add(cell);
                        }
                        sheet.Add(row);
                    }
                }

                // 將修改後的 XML 內容重新寫入 content.xml
                using (var stream = entry.Open())
                {
                    stream.SetLength(0); // 清除原始內容
                    doc.Save(stream);
                }
            }
        }
        //---
    }
}

實際測試,還是有問題,在無 ODS 套件情況,想自己或靠 ChatGPT 的 Code 產出 Excel 2021 可以正常讀取的 .ods 並不容易,運氣好是警告,然後可以讀取,運氣不好是完全不能讀取。

(完)

相關

[研究]LibreOffice 24.8.2 SDK 可以單獨安裝嗎?

[研究]LibreOffice 24.8.2 SDK 可以單獨安裝嗎?

2024-10-29

沒有安裝 LibreOffice 24.8.2,LibreOffice 24.8.2 SDK 可以安裝成功嗎?

https://zh-tw.libreoffice.org/download/download-libreoffice/

LibreOffice_24.8.2_Win_x86-64_sdk.msi









測試是32或64位元版本

C:\Program Files\LibreOffice_24.8_SDK\sdk\cli>sigcheck64.exe *.dll

Sigcheck v2.90 - File version and signature viewer
Copyright (C) 2004-2022 Mark Russinovich
Sysinternals - www.sysinternals.com

C:\Program Files\LibreOffice_24.8_SDK\sdk\cli\cli_basetypes.dll:
        Verified:       Unsigned
        Link date:      ?? 07:25 2024/9/24
        Publisher:      n/a
        Company:        OpenOffice.org
        Description:
        Product:        n/a
        Prod version:   1.0.20.0
        File version:   1.0.20.0
        MachineType:    32-bit
C:\Program Files\LibreOffice_24.8_SDK\sdk\cli\cli_cppuhelper.dll:
        Verified:       Unsigned
        Link date:      ?? 07:47 2024/9/24
        Publisher:      n/a
        Company:        n/a
        Description:    n/a
        Product:        n/a
        Prod version:   n/a
        File version:   n/a
        MachineType:    64-bit
C:\Program Files\LibreOffice_24.8_SDK\sdk\cli\cli_oootypes.dll:
        Verified:       Unsigned
        Link date:      ?? 07:47 2024/9/24
        Publisher:      n/a
        Company:        n/a
        Description:    n/a
        Product:        n/a
        Prod version:   n/a
        File version:   n/a
        MachineType:    32-bit
C:\Program Files\LibreOffice_24.8_SDK\sdk\cli\cli_ure.dll:
        Verified:       Unsigned
        Link date:      ?? 07:47 2024/9/24
        Publisher:      n/a
        Company:        OpenOffice.org
        Description:
        Product:        n/a
        Prod version:   1.0.23.0
        File version:   1.0.23.0
        MachineType:    32-bit
C:\Program Files\LibreOffice_24.8_SDK\sdk\cli\cli_uretypes.dll:
        Verified:       Unsigned
        Link date:      ?? 07:47 2024/9/24
        Publisher:      n/a
        Company:        n/a
        Description:    n/a
        Product:        n/a
        Prod version:   n/a
        File version:   n/a
        MachineType:    32-bit

C:\Program Files\LibreOffice_24.8_SDK\sdk\cli>

DLL 檔案的用途說明:

  • cli_basetypes.dll:此 DLL 提供了基本類型的定義和支援,通常用於處理基本數據類型,例如整數、浮點數和其他基本類型的功能。
  • cli_cppuhelper.dll:這個 DLL 提供了 C++ UNO (Universal Network Objects) 的輔助工具,通常用於 UNO 組件的管理和操作。它為開發者提供了便捷的 API 來處理 C++ UNO 對象。
  • cli_oootypes.dll:此 DLL 定義了與 LibreOffice 中的基本 UNO 對象相關的類型,主要用於與 LibreOffice API 進行交互。它提供了一些基本的 UNO 類型和接口。
  • cli_ure.dll:這個 DLL 是 URE (Universal Runtime Environment) 的一部分,提供了 UNO 的運行時環境,支援多種語言的 UNO 組件,並確保這些組件能在 LibreOffice 中正常運行。
  • cli_uretypes.dll:此 DLL 定義了 URE 中的基本類型,支援在 UNO 和 LibreOffice 中使用的常見數據類型。它幫助開發者在其應用程式中正確處理這些類型。

(完)

[研究]LibreOffice 邁入 24.x 版時代

[研究]LibreOffice 邁入 24.x 版時代

2024-10-29

https://zh-tw.libreoffice.org/download/download-libreoffice/

發現以前提供7.6.x版下載,現在發現沒了。(何時變的敝人不知)








(下圖)檢查更新,目前 7.6.7.2,顯示可更新到24.2.6版 (上圖下方的版本)




但是下方的 SDK 只提供 24.8.2,不提供 24.2.6版。


(完)




2024年5月21日 星期二

[研究]LibreOffice 7.4.6.2 更新 24.2.3

[研究]LibreOffice 7.4.6.2 更新 24.2.3

2024-05-21

LibreOffice 7.4.6.2 更新至 24.2.3 版本,帶來了一些新功能和改進。以下是一些主要變更:

  • 評註樣式:在 LibreOffice 24.2 中,您可以更輕鬆地自訂評註樣式,使其更適合您的需求。
  • Calc 中的欄/列突顯:在 Calc 中,您現在可以突顯特定的欄或列,以更清楚地顯示數據。
  • 選項對話方塊搜尋欄位:在選項對話方塊中,新增了搜尋欄位,讓您更快速地找到所需的設定。
  • 至於 ODF 文件版本,LibreOffice 24.2.3 仍然支援 ODF 1.3 版本,並未有更新。如果您需要使用特定的 ODF 版本,請確認您的文件另存為相應的版本。

**********

今天使用 LibreOffice 時,右上角彈出訊系。


(下圖)選「關於LibreOffice」


(下圖)選「檢查是否有更新」






LibreOffice 7.6.7 和 LibreOffice 24.2.3
https://www.libreoffice.org/download/download-libreoffice/

LibreOffice 7.6.7 是 安定版 (Still)
https://zh-tw.libreoffice.org/download/libreoffice-still/
2024-10-29測試,此網址不再存在,自動導向 https://zh-tw.libreoffice.org/download/download-libreoffice/ 網址,不再提供 7.6.x版,表示 24.x 版是正式版本。

LibreOffice 24.2.3 是 新鮮版 (Fresh)
https://zh-tw.libreoffice.org/download/libreoffice-fresh/
2024-10-29測試,此網址不再存在,自動導向 https://zh-tw.libreoffice.org/download/download-libreoffice/ 網址,不再提供 7.6.x版,表示 24.x 版是正式版本。

LibreOffice Security Advisories
https://www.libreoffice.org/about-us/security/advisories/

Libreoffice : Security Vulnerabilities, CVEs
https://www.cvedetails.com/vulnerability-list/vendor_id-11439/product_id-21008/Libreoffice-Libreoffice.html

(完)

2021年8月14日 星期六

[研究]OpenOffice 4.1.10、LibreOffice 7.0.6 支援那些檔案格式 (副檔名)

[研究]OpenOffice 4.1.10、LibreOffice 7.0.6 支援那些檔案格式 (副檔名)

2021-08-14

Apache OpenOffice
https://www.openoffice.org/zh-tw/
Apache_OpenOffice_4.1.10_Win_x86_install_zh-TW.exe

LibreOffice
https://zh-tw.libreoffice.org/download/libreoffice-still/
LibreOffice_7.0.6_Win_x64.msi

LibreOffice 可以儲存成 Excel 的 .xlsx 檔案格式。












********************************************************************************





(完)

2019年8月25日 星期日

[研究] [C#] 使用 LibreOffice 6.2.6 SDK、OpenOffice 4.1.6 SDK讀取/寫入試算表(Calc) 檔案 (.ods)

[研究] [C#] 使用 LibreOffice 6.2.6 SDK、OpenOffice 4.1.6 SDK讀取/寫入試算表(Calc) 檔案 (.ods)

2091-08-24

本測試使用 LibreOffice 6.2.6 SDK,是 x64 版。
https://zh-tw.libreoffice.org/download/libreoffice-still/

OpenOffice SDK 4.1.6 實際測試也可以用 ,但它還在 x86 版。
https://www.openoffice.org/zh-tw/





















(下圖) 測試用的檔案,做好記得要關閉,否則後面程式跑會出錯。

(下圖) 執行結果,抓出 Cell (2,2) 的 9


Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using uno.util;
using unoidl.com.sun.star.beans;
using unoidl.com.sun.star.frame;
using unoidl.com.sun.star.lang;
using unoidl.com.sun.star.sheet;
using unoidl.com.sun.star.table;
using unoidl.com.sun.star.uno;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            string fileName = "";
            Stream myStream = null;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter = "ods files (*.ods)|*.ods|All files (*.*)|*.*";
            openFileDialog1.FilterIndex = 2;
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.InitialDirectory = System.IO.Directory.GetCurrentDirectory();
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = openFileDialog1.OpenFile()) != null)
                    {
                        label1.Text = openFileDialog1.FileName; // 包含路徑
                        string inputFilePath = openFileDialog1.FileName; // 包含路徑

                        fileName = openFileDialog1.FileName; // 包含路徑


                        XComponentContext context = Bootstrap.bootstrap();
                        XMultiServiceFactory factory = (XMultiServiceFactory)context.getServiceManager();
                        XComponentLoader loader = (XComponentLoader)factory.createInstance("com.sun.star.frame.Desktop");

                        PropertyValue[] args1 = new PropertyValue[1];
                        args1[0] = new PropertyValue();
                        args1[0].Name = "Hidden";
                        args1[0].Value = new uno.Any((Boolean)true);

                        XSpreadsheetDocument doc = (XSpreadsheetDocument)loader.loadComponentFromURL("file:///" + fileName, "_blank", 0, args1);
                        XSpreadsheets sheets = doc.getSheets();
                        //XSpreadsheet sheet = (XSpreadsheet)sheets.getByName("Sheet1").Value;
                        XSpreadsheet sheet = (XSpreadsheet)sheets.getByName("工作表1").Value;  //  繁體中文版 Office

                        XCell cell = sheet.getCellByPosition(2, 2);

                        label1.Text = cell.getValue().ToString();
                    }
                }
                catch (unoidl.com.sun.star.uno.Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
    }
}

增加寫入測試

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using uno.util;
using unoidl.com.sun.star.beans;
using unoidl.com.sun.star.frame;
using unoidl.com.sun.star.lang;
using unoidl.com.sun.star.sdbc;
using unoidl.com.sun.star.sheet;
using unoidl.com.sun.star.table;
using unoidl.com.sun.star.uno;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            string fileName = "";
            Stream myStream = null;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter = "ods files (*.ods)|*.ods|All files (*.*)|*.*";
            openFileDialog1.FilterIndex = 2;
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.InitialDirectory = System.IO.Directory.GetCurrentDirectory();
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = openFileDialog1.OpenFile()) != null)
                    {
                        label1.Text = openFileDialog1.FileName; // 包含路徑
                        string inputFilePath = openFileDialog1.FileName; // 包含路徑

                        fileName = openFileDialog1.FileName; // 包含路徑


                        XComponentContext context = Bootstrap.bootstrap();
                        XMultiServiceFactory factory = (XMultiServiceFactory)context.getServiceManager();
                        XComponentLoader loader = (XComponentLoader)factory.createInstance("com.sun.star.frame.Desktop");

                        PropertyValue[] args1 = new PropertyValue[1];
                        args1[0] = new PropertyValue();
                        args1[0].Name = "Hidden";
                        args1[0].Value = new uno.Any((Boolean)true);

                        XSpreadsheetDocument doc = (XSpreadsheetDocument)loader.loadComponentFromURL("file:///" + fileName, "_blank", 0, args1);
                        XSpreadsheets sheets = doc.getSheets();
                        //XSpreadsheet sheet = (XSpreadsheet)sheets.getByName("Sheet1").Value;
                        XSpreadsheet sheet = (XSpreadsheet)sheets.getByName("工作表1").Value;  //  繁體中文版 Office

                        XCell cell = sheet.getCellByPosition(2, 2);

                        label1.Text = cell.getValue().ToString();

                        // ----- Write test
                        cell.setValue(1000);
                        cell = sheet.getCellByPosition(1, 1);
                        cell.setFormula("Title");

                        XStorable xstorable = (XStorable)doc;
                        PropertyValue[] storeProps = new PropertyValue[1];
                        storeProps[0] = new PropertyValue();
                        storeProps[0].Name = "Overwrite";
                        storeProps[0].Value = new uno.Any((Boolean)true);

                        try
                        {
                            String sURL = "file:///d:/Temp/SaveTest2.ods";
                            xstorable.storeAsURL(sURL, storeProps);
                            //if (doc != null)
                            //{
                            //    //XCloseable xCloseable = (XCloseable)doc;
                            //    //xCloseable.close();
                            //    doc = null;
                            // }
                        }
                        catch (unoidl.com.sun.star.uno.Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
                catch (unoidl.com.sun.star.uno.Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
    }
}



********************************************************************************
2020-05-21 補充

安裝 LibreOffice_6.3.6_Win_x64_sdk.msi,不安裝 LibreOffice_6.3.6_Win_x64.msi
( 實際測試只安裝 SDK,不安裝 LibreOffice 本身) 
Visual Studio 2019 v16.6.0 ,方案使用 .NET Framework 4.7.2 或 4.8,編譯正常,執行出錯


WindowsFormsApp1.exe' (CLR v4.0.30319: DefaultDomain): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: DefaultDomain): 已載入 'C:\CodeTemp\WindowsFormsApp1\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe'。已載入符號。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\CodeTemp\WindowsFormsApp1\WindowsFormsApp1\bin\Debug\cli_basetypes.dll'。建置的模組沒有符號。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\CodeTemp\WindowsFormsApp1\WindowsFormsApp1\bin\Debug\cli_uretypes.dll'。建置的模組沒有符號。
於 System.BadImageFormatException 擲回例外狀況: 'System.Windows.Forms.dll'
類型 'System.BadImageFormatException' 的未處理例外狀況發生於 System.Windows.Forms.dll
無法載入檔案或組件 'cli_cppuhelper, Version=1.0.23.0, Culture=neutral, PublicKeyToken=ce2cb7e279207b9e' 或其相依性的其中之一。 試圖載入格式錯誤的程式。

'[8552] WindowsFormsApp1.exe: 程式追蹤' 程式以返回碼 0 (0x0) 結束。
'[8552] WindowsFormsApp1.exe' 程式以返回碼 -1 (0xffffffff) 結束。

把 LibreOffice 6.3.6.2 安裝了,關閉方案,重新開啟,依然是編譯成功,執行失敗。

把參照  cli_cppuhelper 移除,編譯到下面這行失敗。
 XComponentContext context = Bootstrap.bootstrap();

暫時解決不了。

********************************************************************************
2020-05-21 補充

loader.loadComponentFromURL() 只能用於 .NET Framework 的 Windows Form App 桌面應用程式,無法用 ASP.NET 的 WinForms 網頁程式。

********************************************************************************
2020-05-21 補充

移除 LibreOffice 和 LibreOffice SDK,改安裝
Apache_OpenOffice-SDK_4.1.7_Win_x86_install_en-US.exe
沒安裝 Apache_OpenOffice_4.1.7_Win_x86_install_zh-TW.exe

Visual Studio 2019 v16.6.0 中,把程式的舊參照砍光,參照改用
C:\Program Files (x86)\OpenOffice_4.1.7_SDK\sdk\cli
目錄的,編譯成功,執行失敗。

WindowsFormsApp1.exe' (CLR v4.0.30319: DefaultDomain): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: DefaultDomain): 已載入 'C:\CodeTemp\WindowsFormsApp1\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe'。已載入符號。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\CodeTemp\WindowsFormsApp1\WindowsFormsApp1\bin\Debug\cli_basetypes.dll'。建置的模組沒有符號。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\CodeTemp\WindowsFormsApp1\WindowsFormsApp1\bin\Debug\cli_uretypes.dll'。建置的模組沒有符號。
WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_zh-Hant_b77a5c561934e089\mscorlib.resources.dll'。建置的模組沒有符號。
於 System.IO.FileLoadException 擲回例外狀況: 'System.Windows.Forms.dll'
類型 'System.IO.FileLoadException' 的未處理例外狀況發生於 System.Windows.Forms.dll
混合模式組件是針對版本 'v2.0.50727' 的執行階段建置的,無法在沒有其他組態資訊的情況下載入 4.0 執行階段中。

WindowsFormsApp1.exe' (CLR v4.0.30319: WindowsFormsApp1.exe): 已載入 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\common7\ide\PrivateAssemblies\Runtime\Microsoft.VisualStudio.Debugger.Runtime.dll'。已略過載入符號。模組已最佳化,並已啟用 [Just My Code] 偵錯工具選項。
'[6548] WindowsFormsApp1.exe: 程式追蹤' 程式以返回碼 0 (0x0) 結束。
'[6548] WindowsFormsApp1.exe' 程式以返回碼 -1 (0xffffffff) 結束。

(下圖)本電腦是 Windows 10 Version 1909,確認 .NET Framework 2.0 是有安裝的。

又碰上以前某版本 LibreOffice SDK 和 OpenOffice SDK 時碰到的不好經驗了。

(完)

相關

[研究] [C#] 使用 LibreOffice 6.2.6 SDK、OpenOffice 4.1.6 SDK讀取/寫入試算表(Calc) 檔案 (.ods)
https://shaurong.blogspot.com/2019/08/c-libreoffice-626-sdk-calc-ods.html

[研究] [C#] 使用 OpenOffice 4.1.3 SDK 讀取試算表(Calc) 檔案 (.ods)
http://shaurong.blogspot.com/2016/12/c-openoffice-413-sdk-calc-ods.html

[研究] [C#] 使用 LibreOffice 5.1.6、5.3.0 SDK 讀取試算表(Calc) 檔案 (.ods)
http://shaurong.blogspot.com/2016/12/c-libreoffice-516-sdk-calc-ods.html

[研究] [C#] 讀取 LibreOffice、OpenOffice 的試算表(Calc) 檔案 (.ods)(使用 .NET 4.5 的 ZipFile)
http://shaurong.blogspot.com/2016/12/c-libreoffice-516-calc-ods-net-45.html

[研究] [C#] 使用 Apose.Cells 讀取 LibreOffice 5.1.6、OpenOffice 4.1.3 試算表(Calc) 檔案 (.ods)
http://shaurong.blogspot.com/2017/01/c-aposecells-libreoffice-516openoffice.html

[研究] [C#] 使用 GemBox.Spreadsheet 讀取LibreOffice、OpenOffice試算表(Calc) 檔案 (.ods)
http://shaurong.blogspot.com/2016/12/c-gemboxspreadsheet-libreofficeopenoffi.html

[研究] OpenOffice 4.1.3 試算表(Calc) 保護鎖定儲存格不被修改
http://shaurong.blogspot.com/2016/12/openoffice-413-calc.html

[研究] 使用OpenOffice 4.1.3試算表(Calc)建立「下拉式選單」來輸入資料
http://shaurong.blogspot.com/2016/12/openoffice-413calc.html