Quantcast
Channel: Apache OpenOffice Community Forum
Viewing all articles
Browse latest Browse all 1291

External Programs • Re: Spreadsheet created using c# shows empty in OpenOffice

$
0
0
This is code for the OpenOffice API, not Excel API. I followed a few online examples for creating an OpenOffice spreadsheet. If anyone can point me to a more generic example for creating an OpenOffice spreadsheet using the c# API I'll compare that to my code.
Hi. it looks like you are using types like https://learn.microsoft.com/en-us/dotne ... cumenttype, which are certainly part of MS's OpenXML library, not of LO or AOO libraries. Not sure if that matters very much, though ...
Typicall c# code for creating a spreadsheet document looks like this when using LO or AOO libraries

Code:

using System;using  System.Collections.Generic;using  System.Drawing;using  System.IO;using  System.Threading;using unoidl.com.sun.star.awt;using unoidl.com.sun.star.document;using unoidl.com.sun.star.lang;using unoidl.com.sun.star.uno;using unoidl.com.sun.star.bridge;using unoidl.com.sun.star.frame;using unoidl.com.sun.star.sheet;using unoidl.com.sun.star.beans;using unoidl.com.sun.star.container;using unoidl.com.sun.star.drawing;using unoidl.com.sun.star.embed;using unoidl.com.sun.star.table;using unoidl.com.sun.star.text;using unoidl.com.sun.star.util;namespace CSharpDemo {    public class OpenOfficeApp  {        [STAThread]        public static void Main() {            Console.WriteLine("CSharpDemo Start");    // create the desktop            XComponentContext XCC = uno.util.Bootstrap.bootstrap();            XMultiComponentFactory XMCF = (XMultiComponentFactory)XCC.getServiceManager();            XMultiServiceFactory XMSF1 = (XMultiServiceFactory)XCC.getServiceManager();            XComponentLoader XCL = (XComponentLoader)XMSF1.createInstance("com.sun.star.frame.Desktop");    // open the spreadsheet document            PropertyValue[] pPV = new PropertyValue[2];            pPV[0] = new PropertyValue();            pPV[0].Name = "Hidden";            pPV[0].Value = new uno.Any(false);            pPV[1] = new PropertyValue();            pPV[1].Name = "ReadOnly";            pPV[1].Value = new uno.Any(false);            XComponent XCo = XCL.loadComponentFromURL("private:factory/scalc","_blank",0,pPV);        }    }}

Statistics: Posted by ms777 — Sat Nov 23, 2024 12:22 pm



Viewing all articles
Browse latest Browse all 1291

Trending Articles