|
|
Home » Developing U++ » UppHub » Ole Automation [FEATURE REQUEST?]
Re: Ole Automation [FEATURE REQUEST?] [message #21169 is a reply to message #21168] |
Wed, 06 May 2009 12:25 |
|
Hello Koldo!
No problems! I created this temporarily, because I needed this today. You can change as you want, no problems, I only went to suggest this realization!
Will be great set cell/range format:
in MSExcel can be:
Cells(row, col).NumberFormat = "@"
The problems is when i try to write a number as text!
[Updated on: Wed, 06 May 2009 12:27] Report message to a moderator
|
|
|
Re: Ole Automation [FEATURE REQUEST?] [message #21173 is a reply to message #21169] |
Wed, 06 May 2009 14:27 |
|
koldo
Messages: 3394 Registered: August 2008
|
Senior Veteran |
|
|
tojocky wrote on Wed, 06 May 2009 12:25 | Hello Koldo!
No problems! I created this temporarily, because I needed this today. You can change as you want, no problems, I only went to suggest this realization!
Will be great set cell/range format:
in MSExcel can be:
Cells(row, col).NumberFormat = "@"
The problems is when i try to write a number as text!
|
Hello tojocky
Now there is not included a way to set the format, but when you write text, number or dates they has to appear right.
In the demo you see:
sheet.SetValue(2, 2, "=A7*B5");
sheet.SetValue(3, 21, "Hello");
sheet.SetValue("BD25", 23242.343);
sheet.SetValue("B26", GetSysTime());
The output of this should be as expected.
Could you explain me what you need with more detail?.
Best regards
Koldo
Best regards
Iñaki
|
|
|
Re: Ole Automation [FEATURE REQUEST?] [message #21174 is a reply to message #21173] |
Wed, 06 May 2009 15:58 |
|
Hello Koldo,
Try this for Ms Excel in demo example:
sheet.SetValue(1, 2, "123456789123456789");
I have lost data:
for this example in excel I have "123456789123456000" instead "123456789123456789"
I was modified a little the code:
bool MSSheet::SetValue(int col, int row, Value value)
{
if (!Sheet)
return false;
VariantOle x, y, val;
x.Int4(col);
y.Int4(row);
val.Value(value);
// >>> Ion Lupascu 06.05.2009 Set Cell Format for string cell
if (!(Range = Ole::GetObject(Sheet, "Cells", x, y)))
return false;
if(IsString(value)){
VariantOle txt_format_ole;
txt_format_ole.BString("@");
Ole::SetValue(Range, "NumberFormat", txt_format_ole);
}
return Ole::SetValue(Range, "Value", val);
// <<< Ion Lupascu 06.05.2009
}
I thing that exist memory leak in the program!
Every time when I run the program that it only preparing excel file and text file (specific converting from text to excel file) I have memory leak. Memory usage is increasing every time!
Is it a normal situation?
[Updated on: Wed, 06 May 2009 16:12] Report message to a moderator
|
|
|
|
Re: Ole Automation [FEATURE REQUEST?] [message #21181 is a reply to message #21179] |
Thu, 07 May 2009 09:18 |
|
Hello Koldo!
I tested from svn and do not found your changes about adding in package organizer "gdi32" for package SysInfo and in demo package the code:
sheet.SetValue(1, 2, "'123456789123456789");
Maybe I do not check correct svn repository?
I use:
http://upp-mirror.googlecode.com/svn/trunk/
Edit: I want to add that to add a symbol as ' is not a solution!
May be will be great to add method SetFormatSelection that as parameter will be an enum with restricted values as (String)?
It will be nice because the format realization for MS Excel can differ by Open Office Calc!
[Updated on: Thu, 07 May 2009 09:27] Report message to a moderator
|
|
|
|
Re: Ole Automation [FEATURE REQUEST?] [message #21186 is a reply to message #21185] |
Fri, 08 May 2009 08:16 |
|
Hello Koldo!
My Opinion about adding the method "SetSelectionFormat" is important, for me. This method can resolve my problems.
I suggest to add this method:
bool MSSheet::SetValue(Value value)
{
if (!Sheet)
return false;
if (!Range)
return false;
VariantOle val;
val.Value(value);
return Ole::SetValue(Range, "Value", val);
}
I realized only for MSExcel variant!
Other methods to do is important too!
Thank you for realization!
|
|
|
|
|
|
Re: Ole Automation [FEATURE REQUEST?] [message #21332 is a reply to message #21330] |
Wed, 13 May 2009 14:59 |
|
koldo wrote on Wed, 13 May 2009 15:09 | Thank you tojocky
I agree they are good samples of accesing directly Microsoft formats.
Other good effort is Jakarta POI. The problem of it is that it is addressed to Java.
When thinking in Automation package I was tempted to access directly the files. The advantage was clear: you do not need the Office software to do it and you do not depend on the OS (how to access Microsoft files from GNU/Linux?).
The problem I had was that .xls, .doc, .ods, .otd are from complex to very complex formats and I did not found libraries that covered their main features.
Finally I chose to go through Ole automation and UNO api. For me they have not been easy to use. Bad documented from a C point of view after many efforts I had to refuse to use UNO to handle OpenOffice and so to handle it from Linux as there is no Ole clone.
Well, that is my experience. More ideas are acknowledged.
Best regards
Koldo
|
I founded and MSWord too!
But the MSOffice 2007 is based on XML file compressed with gzip.
May we try to concentrate our power to manipulate direct with file (.xls, xlsx, .doc, .docx)?
Other formats I do not use!
|
|
|
|
Re: Ole Automation [FEATURE REQUEST?] [message #21345 is a reply to message #17864] |
Thu, 14 May 2009 08:14 |
mr_ped
Messages: 825 Registered: November 2005 Location: Czech Republic - Praha
|
Experienced Contributor |
|
|
Many parts of Open XML definition are optional, i.e. you don't need to support them. edit: some of those optional are defined in a funny way like "following behavior of some legacy SW" without further details, so even if you try to support it, you will fail.
Then again it's just question of time when Microsoft Office will produce files (even simple ones) with so many optional tags as possible to prevent anybody else working with that format, so I would not bother too much with that ISO standard.
The ODF is other kind of beast, you can 100% support the ISO standard, yet for example it doesn't say nothing particular about formulas in spreadsheets, so you are still not supporting real world ODF files very good. If you want to support real world files, you must also follow current Open Office way of doing things. This situation has at least the advantage that the OOo legacy is de facto standard which will work, the only ODF vendor breaking this is Microsoft (are you surprised? ) with latest MS Office service pack they do support the ISO part of ODF and everything else what will become part of version2 of ODF definition they do in different way, so their support of ODF "is there", but practically unusable.
[Updated on: Thu, 14 May 2009 08:16] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 11:51:52 CEST 2024
Total time taken to generate the page: 0.03420 seconds
|
|
|