Calc C#CLI programming(转贴)
来源:互联网 发布:linux显示环境变量 编辑:程序博客网 时间:2024/06/05 18:58
http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=18569
My working sample code to open a sheet and access to cells:
----------------------------------------------------
using System;
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.beans;
using unoidl.com.sun.star.sheet;
using unoidl.com.sun.star.table;
namespace OOoCDIConsoleSample
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
unoidl.com.sun.star.uno.XComponentContext
m_xContext;
unoidl.com.sun.star.lang.XMultiServiceFactory
mxMSFactory;
unoidl.com.sun.star.sheet.XSpreadsheetDocument
mxDocument;
unoidl.com.sun.star.container.XIndexAccess
xSheetsIA;
unoidl.com.sun.star.sheet.XSpreadsheets
xSheets;
unoidl.com.sun.star.sheet.XSpreadsheet
xSheet;
unoidl.com.sun.star.table.XCell
xCell;
try
{
// get the remote office component context
m_xContext = uno.util.Bootstrap.bootstrap();
Console.WriteLine("Connected to a running
office ...");
mxMSFactory = (XMultiServiceFactory)
m_xContext.getServiceManager();
String available = (mxMSFactory != null ?
"available" : "not available");
Console.WriteLine( "remote ServiceManager is
" + available );
XComponentLoader aLoader =
(XComponentLoader)
mxMSFactory.createInstance(
"com.sun.star.frame.Desktop" );
XComponent xComponent =
aLoader.loadComponentFromURL
(
"file:///C:/x.ods",
"_blank",
0,
new
unoidl.com.sun.star.beans.PropertyValue[0]
);
mxDocument =
(unoidl.com.sun.star.sheet.XSpreadsheetDocument) xComponent;
xSheets =mxDocument.getSheets();
xSheetsIA =
(unoidl.com.sun.star.container.XIndexAccess) xSheets;
xSheet =
(unoidl.com.sun.star.sheet.XSpreadsheet) xSheetsIA.getByIndex( 1 ).Value;
//xSheet =
(unoidl.com.sun.star.sheet.XSpreadsheet) xSheetsIA.getByName("Project");
xCell = xSheet.getCellByPosition( 0, 0 );
Console.WriteLine("Cell value = '" +
xCell.getValue() + "'");
Console.WriteLine("Cell Type1 = '" +
xCell.getType() + "'");
Console.WriteLine("Cell Type2 = '" +
xCell.GetType() + "'");
Console.WriteLine("Cell Formula= '" +
xCell.getFormula() + "'");
Console.WriteLine("Cell Error = '" +
xCell.getError() + "'");
xCell.setValue(123);
Console.WriteLine("Cell value = '" +
xCell.getValue() + "'");
Console.WriteLine("Cell Type1 = '" +
xCell.getType() + "'");
Console.WriteLine("Cell Type2 = '" +
xCell.GetType() + "'");
Console.WriteLine("Cell Formula= '" +
xCell.getFormula() + "'");
Console.WriteLine("Cell Error = '" +
xCell.getError() + "'");
xSheets.insertNewByName("NewTabCDI", 0);
xSheets.moveByName("NewTabCDI", 2);
Console.ReadLine();
xComponent.dispose();
}
catch (System.Exception ex)
{
Console.WriteLine(ex.ToString());
}
Console.ReadLine();
}
}
}
- Calc C#CLI programming(转贴)
- Creating an OpenOffice Calc Document with C#(转贴)
- C++/CLI ??
- c++/cli
- C++/CLI
- C++/CLI
- C++/CLI
- C++/CLI
- C++/CLI
- calc
- Calc
- calc()
- 我看C++/CLI(转贴)
- C++:C++/CLI
- C++/CLI 简单介绍
- C++/CLI前途如何?
- C++/CLI简介
- 《C++/CLI in Action》
- Creating an OpenOffice Calc Document with C#(转贴)
- man 手册不全
- 将帮助页转换为PDF文件
- CXF简单实现web service服务器端
- New draft of VoiceXML 3 published today
- Calc C#CLI programming(转贴)
- 货币与银行的五个核心原则
- silverlight3.0 可视化设计器不能显示问题
- MyEclipse6.5注册码
- Oracle透明网关 for SQL Server
- 发现新大陆
- 观点:程序员要培养企业家式的能力
- FCKeditor
- 百度推出类似Chorme OS操作系统的说法纯属瞎扯蛋