logo       

RE: Calc C#CLI programming - Get the used range in a sheet - XUsedAreaCurs: msg#00130

openoffice.devel.general

Subject: RE: Calc C#CLI programming - Get the used range in a sheet - XUsedAreaCursor

Thanks for your help Juergen.

I try this.

unoidl.com.sun.star.sheet.XSheetCellCursor
xCursor = xSheet.createCursor();

unoidl.com.sun.star.sheet.XUsedAreaCursor
xUsedCursor =
(unoidl.com.sun.star.sheet.XUsedAreaCursor)xCursor;
xUsedCursor.gotoStartOfUsedArea(true);
xUsedCursor.gotoEndOfUsedArea(true);

But I don't find the way to extract the range of used cells.

Accessible methods for xUsedCursor are:
xUsedCursor.Equals()
xUsedCursor.GetHashCode()
xUsedCursor.GetType()
xUsedCursor.gotoStartOfUsedArea()
xUsedCursor.gotoEndOfUsedArea()
xUsedCursor.ToString()

I miss someting in the access principle.

Thank's for your help.

------------------------------
Paul Veuve
vep@xxxxxxxx
------------------------------
CDI CONSEILS ET DEVELOPPEMENTS
INDUSTRIELS SA
Chemin de la Justice 15
CH-2000 NEUCHATEL
------------------------------
http://www.cdisa.ch

Phone (+41 32) 733 31 31
or (+41 78) 600 31 31

Fax (+41 32) 733 31 32
------------------------------
-----Message d'origine-----
De : Juergen Schmidt [mailto:juergen.schmidt@xxxxxxx]
Envoyé : mardi, 21. novembre 2006 17:36
À : dev@xxxxxxxxxxxxxx
Objet : Re: [dev] Calc C#CLI programming

Paul Veuve wrote:
> Hello Juergen,
>
> Thank's for your answer.
>
>>> XStorable.store() ..
>
> But, how can I link the XStorable object to the
> unoidl.com.sun.star.sheet.XSpreadsheetDocument ?.

i would expect

unoidl.com.sun.star.frame.XStorable xStore; xStore =
(unoidl.com.sun.star.frame.XStorable) xComponent;

>
>>> - get the used cell range for the selected sheet
>
> Get the used range in a sheet:
> B5 and D3 are not empty -> range would be A0:D5

i haven't a final solution in place but you should play with

- got the XSheetCellCursor -> supports XUsedAreaCursor

- use the XUsedAreaCursor
goto start -> expand to the end -> you should now have the active range

sorry, that i haven't a working snippet 8no time to test it in detail)

Juergen

>
> I would like also get the cell or a collection of cells containing a
> given value or formula (ex: cells containing "MyText")
>
>>> In general it is a good idea to ask this kind of question on the
>>> dev@api
> mailing list
> I do bus was not successful.
>
> Thanks for your help.
>
> ------------------------------
> Paul Veuve
> vep@xxxxxxxx
> ------------------------------
> CDI CONSEILS ET DEVELOPPEMENTS
> INDUSTRIELS SA
> Chemin de la Justice 15
> CH-2000 NEUCHATEL
> ------------------------------
> http://www.cdisa.ch
>
> Phone (+41 32) 733 31 31
> or (+41 78) 600 31 31
>
> Fax (+41 32) 733 31 32
> ------------------------------
> -----Message d'origine-----
> De : Juergen Schmidt [mailto:juergen.schmidt@xxxxxxx] Envoyé : mardi,
> 21. novembre 2006 07:23 À : dev@xxxxxxxxxxxxxx Objet : Re: [dev] Calc
> C#CLI programming
>
> Hi Paul,
>
> Paul Veuve wrote:
>> Hello,
>>
>> I am using Calc with uno in C# (CLI VS2003).
>>
>> But don't find,in CLI C#, howto:
>> - save document
>
> The good ting is that it is one API for all languages, it should be
> relatively easy to translate examples from C++ or Java to C#. In case
> of saving use simply one of the following methods
>
> XStorable.store() without parameter, store the document under the same
> Url XStorable.storeSelf( ....) parameter with optional values for
> saving
>
>
>> - get the used cell range for the selected sheet
> what do you exactly mean here
>
>
> In general it is a good idea to ask this kind of question on the
> dev@api mailing list
>
> Juergen
>
>> There is unfortunately no sample for this in C#.
>> I have some trouble to find the way to convert Java sample to C#.
>>
>> Thanks for your help
>>
>> 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();
>> }
>> }
>> }
>>
>> ------------------------------
>> Paul Veuve
>> vep@xxxxxxxx
>> ------------------------------
>> CDI CONSEILS ET DEVELOPPEMENTS
>> INDUSTRIELS SA
>> Chemin de la Justice 15
>> CH-2000 NEUCHATEL
>> ------------------------------
>> http://www.cdisa.ch
>>
>> Phone (+41 32) 733 31 31
>> or (+41 78) 600 31 31
>>
>> Fax (+41 32) 733 31 32
>> ------------------------------



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.21/589 - Release Date: 15.12.2006
17:10



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise