U++ framework
Do not panic. Ask here before giving up.

Home » Developing U++ » UppHub » Ole Automation [FEATURE REQUEST?]
Ole Automation [FEATURE REQUEST?] [message #17864] Sun, 31 August 2008 21:20 Go to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello all

Do you have any program using Upp++ for Ole automation? (only windows). This serve to handle not only Office programs like Excel or Word but other like Catia 5.

If it does exist it could be prepared as a class that may be added to Bazaar.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #18729 is a reply to message #17864] Sat, 18 October 2008 21:02 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello all

I am doing the job.

Next week I expect to have the first sample of a basic class to handle Excel spreadsheets.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #19067 is a reply to message #18729] Sat, 08 November 2008 14:38 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
koldo wrote on Sat, 18 October 2008 15:02

Hello all

I am doing the job.

Next week I expect to have the first sample of a basic class to handle Excel spreadsheets.

Best regards
Koldo


Cute. Have you succeeded?

Mirek
Re: Ole Automation [FEATURE REQUEST?] [message #19075 is a reply to message #19067] Sun, 09 November 2008 17:11 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello luzr

Yes. I did some functions to handle Ole and a small demo filling an excel spreadsheet.

As I did not see any answer about this I centered to other functions, but after that I wanted to do the job.

Here I enclose you the public: side of the class declaration that is implemented.

class MSSheet
{
public:
	MSSheet();
	~MSSheet();
	
	bool AddSheet();
	bool OpenSheet(String fileName);
	bool SetVisible(bool);
	bool SetValue(int row, int col, String value);
	String GetValue(int row, int col);
	bool FillRange(String range);
	bool SetSaved(bool);
	bool SaveAs(String fileName, String type = "excel");
	void Quit();
};


I wanted to extend this class and to add other classes like MSText and Catia (to handle CAD program Dassault Catia V) as I know rather well the ole interface to them.

I was wondering too if doing something similar with OpenOffice so with the same set of functions we could handle both programs. But it is not very easy so I wanted to go step by step.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #19171 is a reply to message #19075] Sun, 16 November 2008 18:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
koldo wrote on Sun, 09 November 2008 11:11

Hello luzr

Yes. I did some functions to handle Ole and a small demo filling an excel spreadsheet.

As I did not see any answer about this I centered to other functions, but after that I wanted to do the job.

Here I enclose you the public: side of the class declaration that is implemented.

class MSSheet
{
public:
	MSSheet();
	~MSSheet();
	
	bool AddSheet();
	bool OpenSheet(String fileName);
	bool SetVisible(bool);
	bool SetValue(int row, int col, String value);
	String GetValue(int row, int col);
	bool FillRange(String range);
	bool SetSaved(bool);
	bool SaveAs(String fileName, String type = "excel");
	void Quit();
};


I wanted to extend this class and to add other classes like MSText and Catia (to handle CAD program Dassault Catia V) as I know rather well the ole interface to them.

I was wondering too if doing something similar with OpenOffice so with the same set of functions we could handle both programs. But it is not very easy so I wanted to go step by step.

Best regards
Koldo


Great job. Any plans makeing them public? Smile

Mirek
Re: Ole Automation [FEATURE REQUEST?] [message #19191 is a reply to message #19171] Wed, 19 November 2008 08:00 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello luzr

Well... after the SysInfo functions first version release and full test I will follow working with it.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #19447 is a reply to message #17864] Thu, 04 December 2008 12:09 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello luzr

After first batch of SysInfo I will have first batch of Automation functions ready on December including MSSheet and MSText.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #19656 is a reply to message #17864] Tue, 30 December 2008 10:49 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello all

Ole Automation status:
- Access to MSOffice completed (Msc and MinGW tested)
- Access to OpenOffice
-- Using Ole: in progress
--- This interface only works in Windows
--- Expected to end in one week. Sorry for the delay
-- Using UNO: stopped!
--- This interface would work in Linux and Windows
--- I have spent many hours but it is too hard for me! (HELP REQUESTED)

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #19776 is a reply to message #17864] Sat, 17 January 2009 00:22 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello all

I am very happy to include in Bazaar the Automation library and a console demo.

It handles OpenOffice Calc and Writer and Microsoft Excel and Word.

I have prepared it thinking in simplicity. For example:

OfficeDoc doc;

if (OfficeDoc::IsAvailable("Open"))
    doc.Init("Open")
else if (OfficeDoc::IsAvailable("Microsoft"))
    doc.Init("Microsoft")
else
    return;

doc.SetFont("Arial", 14);
doc.SetBold(true);
doc.WriteText("Hello all!");
doc.SetFont("Arial", 12); 
doc.SetBold(false);
doc.SetItalic(true);
doc.WriteText("\n\nNon me latet [To replace] nonnullos vestrum");
doc.Select();
doc.Replace("[To replace]", "replaced text");

doc.Print();

doc.SaveAs("FileDemo", "doc");
doc.Quit();  


So with the same set of functions it manages OpenOffice and Microsoft Office transparently fo the programmer.

The main classes declaration is like this:

class OfficeSheet
{
public:
	OfficeSheet();
	~OfficeSheet();
	
	static bool IsAvailable(String type);
	
	bool Init(char *type);
	
	bool AddSheet(bool visible);
	bool OpenSheet(String fileName, bool visible);
	
	bool SetValue(int col, int row, Value value);
	bool SetValue(String cell, Value value);
	Value GetValue(int col, int row);
	Value GetValue(String cell);
	bool Replace(Value search, Value replace);
		
	bool SetBold(int col, int row, bool bold);
	bool SetBold(String cell, bool bold);
	bool SetBold(bool bold);
	bool SetFont(int col, int row, String name, int size);
	bool SetFont(String cell, String name, int size);
	bool SetFont(String name, int size);
	
	bool Select(String range);
	bool Select(int fromX, int fromY, int toX, int toY);
	bool Select();
	
	bool Print();
	
	bool SaveAs(String fileName, String type = "xls");
	bool Quit();
};

class OfficeDoc
{
public:
	OfficeDoc();
	~OfficeDoc();
	
	static bool IsAvailable(char *program);
	
	bool Init(char *type);
	
	bool AddDoc(bool visible);
	bool OpenDoc(String fileName, bool visible);

	bool SetFont(String font, int size);
	bool SetBold(bool bold);
	bool SetItalic(bool italic);
	bool WriteText(String value);
	
	bool Select();
	
	bool Replace(String search, String replace);
	
	bool Print();
	
	bool SetSaved(bool);
	bool SaveAs(String fileName, String type = "doc");
	bool Quit();
};


Unfortunately it only works in Windows (MinGW and MSC) using Ole Automation. As I have explained before the OpenOffice official interface called UNO has been too much for me until now.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21147 is a reply to message #19776] Tue, 05 May 2009 13:06 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello Koldo!
Thank you for interesting OleAutomation.
I tried to buid Automation demo console with MSC9 and have following errors:
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__DeleteDC@4 referenced in function "bool __cdecl Window_SaveCap
	ture(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__DeleteObject@4 referenced in function "bool __cdecl Window_Sav
	eCapture(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__GetDIBits@28 referenced in function "bool __cdecl Window_SaveC
	apture(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__BitBlt@36 referenced in function "bool __cdecl Window_SaveCapt
	ure(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__SelectObject@8 referenced in function "bool __cdecl Window_Sav
	eCapture(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__CreateCompatibleBitmap@12 referenced in function "bool __cdecl
	 Window_SaveCapture(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__CreateCompatibleDC@4 referenced in function "bool __cdecl Wind
	ow_SaveCapture(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
C:\upp\out\MSC9.Force_size.Mt\Automation demo console.exe : fatal error LNK1120: 7 unresolved externals

With GCC MINGW have not errors and works fine!
Re: Ole Automation [FEATURE REQUEST?] [message #21148 is a reply to message #19776] Tue, 05 May 2009 13:57 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Sorry... repeated!

[Updated on: Tue, 05 May 2009 13:57]

Report message to a moderator

Re: Ole Automation [FEATURE REQUEST?] [message #21150 is a reply to message #21147] Tue, 05 May 2009 15:03 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello tojocky

All the functions not found by the linker are in gdi32.lib so it seems the compiler does not found it for MSC.

Please check if in "Build methods" menu for MSC in LIB directories it appears the directory "C:\Program Files\Microsoft SDKs\Windows\v6.1\lib". Gdi32.lib is located there for MSC.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21151 is a reply to message #21150] Tue, 05 May 2009 15:52 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

SDK libs is in "C:\Program Files\Microsoft Visual Studio 9.0\Vc\Lib"
Is configured in "Build methods"!

file Gdi32.lib I founded by address: C:\Program Files\Microsoft Visual Studio 9.0\Vc\Lib!

[Updated on: Tue, 05 May 2009 15:53]

Report message to a moderator

Re: Ole Automation [FEATURE REQUEST?] [message #21152 is a reply to message #21151] Tue, 05 May 2009 16:53 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello tojocky

Excuse me Smile. Your answer is clear, but in my theide I have this:

index.php?t=getfile&id=1710&private=0

After Visual C++ Express and SDK installation, gdi32.lib file is installed under "Microsoft SDKs".

Please confirm me that gdi32.lib file is located under

C:\Program Files\Microsoft Visual Studio 9.0\Vc\Lib

instead of under

C:\Program Files\Microsoft SDKs\Windows\v6.1\lib

Best regards
Koldo
  • Attachment: Screen.JPG
    (Size: 65.43KB, Downloaded 2221 times)


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21156 is a reply to message #21152] Tue, 05 May 2009 21:33 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello Koldo,

I have the same situation with this difference:
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib"

instead

"C:\Program Files\Microsoft SDKs\Windows\v6.1\lib"

index.php?t=getfile&id=1711&private=0

The gdi32.lib library is located in folder:

"C:\Program Files\Microsoft SDKs\Windows\v6.1\lib"

I want to notice that when i tried to build this demo under MSC8 with the latest source svn code I have following errors:

----- SysInfo ( MT MSC8 FORCE_SIZE WIN32 MSC ) (3 / 5)
SysInfo.cpp
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1179) : error C2065: 'PRODUCT_ULTIMATE' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1179) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1182) : error C2065: 'PRODUCT_HOME_PREMIUM' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1182) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1185) : error C2065: 'PRODUCT_HOME_BASIC' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1185) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1188) : error C2065: 'PRODUCT_ENTERPRISE' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1188) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1191) : error C2065: 'PRODUCT_BUSINESS' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1191) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1194) : error C2065: 'PRODUCT_STARTER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1194) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1197) : error C2065: 'PRODUCT_CLUSTER_SERVER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1197) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1200) : error C2065: 'PRODUCT_DATACENTER_SERVER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1200) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1203) : error C2065: 'PRODUCT_DATACENTER_SERVER_CORE' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1203) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1206) : error C2065: 'PRODUCT_ENTERPRISE_SERVER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1206) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1209) : error C2065: 'PRODUCT_ENTERPRISE_SERVER_CORE' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1209) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1212) : error C2065: 'PRODUCT_ENTERPRISE_SERVER_IA64' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1212) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1215) : error C2065: 'PRODUCT_SMALLBUSINESS_SERVER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1215) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1218) : error C2065: 'PRODUCT_SMALLBUSINESS_SERVER_PREMIUM' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1218) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1221) : error C2065: 'PRODUCT_STANDARD_SERVER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1221) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1224) : error C2065: 'PRODUCT_STANDARD_SERVER_CORE' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1224) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1227) : error C2065: 'PRODUCT_WEB_SERVER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1227) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1230) : warning C4060: switch statement contains no 'case' or 'default' labels
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1233) : error C2065: 'SM_SERVERR2' : undeclared identifier
SysInfo: 1 file(s) built in (0:01.29), 1297 msecs / file, duration = 1312 msecs, parallelization 0%

There were errors. (0:01.39)


Thank you for you contribution!

After build this with MINGW I can propouse to divide OfficeSheet into OfficeBook and OfficeSheet. It can be add possibility to add more sheets under one book (file)!
  • Attachment: untitled.JPG
    (Size: 66.08KB, Downloaded 2194 times)
Re: Ole Automation [FEATURE REQUEST?] [message #21157 is a reply to message #21156] Wed, 06 May 2009 00:02 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello tojocky

- About the gdi32.lib problem

The issue is to link the program with gdi32.lib

index.php?t=getfile&id=1712&private=0

I have tested it now with v6.1 and v6.0A and both link and run well Confused . Please check it and tell me what happens.


- About MSC8 "undeclared identifier" errors

Reading sysinfo.cpp from line around 1100 you will see:

#if defined(__MINGW32__)

//#define PRODUCT_UNDEFINED                       0x00000000

#define PRODUCT_ULTIMATE                        0x00000001
#define PRODUCT_HOME_BASIC                      0x00000002
#define PRODUCT_HOME_PREMIUM                    0x00000003
...


They serve to define Win OS version.

As I have only tested this with MinGW and MSC9 I saw that these includes where in ...\Microsoft SDKs\Windows\v6.1\Include\WinNT.h, so they were included for MinGW as MSC9 did not need them.

The SM_SERVERR2 #include is in ...\Microsoft SDKs\Windows\v6.1\Include\WinUser.h and in ...\mingw\include\winuser.h, so I did not include it.

For using them in MSC8 they would have to be included.


- About Sheets and Books

Ok. Let me some days and I will do it.


Thank you for testing and giving feedback Smile

Best regards
Koldo

  • Attachment: Screen.JPG
    (Size: 56.51KB, Downloaded 2077 times)


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21158 is a reply to message #21157] Wed, 06 May 2009 06:05 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello Koldo!
When I put gdi32 in "package organizer" for SysInfo with MSC9 was compile and run OK! Please change this in svn (bazaar) too!

With MSC8 I modified your code and works too:

i modified:
#if !defined(PRODUCT_ULTIMATE)
#define PRODUCT_ULTIMATE                        0x00000001
#define PRODUCT_HOME_BASIC                      0x00000002
#define PRODUCT_HOME_PREMIUM                    0x00000003
#define PRODUCT_ENTERPRISE                      0x00000004
#define PRODUCT_HOME_BASIC_N                    0x00000005
#define PRODUCT_BUSINESS                        0x00000006
#define PRODUCT_STANDARD_SERVER                 0x00000007
#define PRODUCT_DATACENTER_SERVER               0x00000008
#define PRODUCT_SMALLBUSINESS_SERVER            0x00000009
#define PRODUCT_ENTERPRISE_SERVER               0x0000000A
#define PRODUCT_STARTER                         0x0000000B
#define PRODUCT_DATACENTER_SERVER_CORE          0x0000000C
#define PRODUCT_STANDARD_SERVER_CORE            0x0000000D
#define PRODUCT_ENTERPRISE_SERVER_CORE          0x0000000E
#define PRODUCT_ENTERPRISE_SERVER_IA64          0x0000000F
#define PRODUCT_BUSINESS_N                      0x00000010
#define PRODUCT_WEB_SERVER                      0x00000011
#define PRODUCT_CLUSTER_SERVER                  0x00000012
#define PRODUCT_HOME_SERVER                     0x00000013
#define PRODUCT_STORAGE_EXPRESS_SERVER          0x00000014
#define PRODUCT_STORAGE_STANDARD_SERVER         0x00000015
#define PRODUCT_STORAGE_WORKGROUP_SERVER        0x00000016
#define PRODUCT_STORAGE_ENTERPRISE_SERVER       0x00000017
#define PRODUCT_SERVER_FOR_SMALLBUSINESS        0x00000018
#define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM    0x00000019

#define PRODUCT_UNLICENSED                      0xABCDABCD

#define SM_SERVERR2             89
#endif



instead:

#if defined(__MINGW32__)

//#define PRODUCT_UNDEFINED                       0x00000000

#define PRODUCT_ULTIMATE                        0x00000001
#define PRODUCT_HOME_BASIC                      0x00000002
#define PRODUCT_HOME_PREMIUM                    0x00000003
#define PRODUCT_ENTERPRISE                      0x00000004
#define PRODUCT_HOME_BASIC_N                    0x00000005
#define PRODUCT_BUSINESS                        0x00000006
#define PRODUCT_STANDARD_SERVER                 0x00000007
#define PRODUCT_DATACENTER_SERVER               0x00000008
#define PRODUCT_SMALLBUSINESS_SERVER            0x00000009
#define PRODUCT_ENTERPRISE_SERVER               0x0000000A
#define PRODUCT_STARTER                         0x0000000B
#define PRODUCT_DATACENTER_SERVER_CORE          0x0000000C
#define PRODUCT_STANDARD_SERVER_CORE            0x0000000D
#define PRODUCT_ENTERPRISE_SERVER_CORE          0x0000000E
#define PRODUCT_ENTERPRISE_SERVER_IA64          0x0000000F
#define PRODUCT_BUSINESS_N                      0x00000010
#define PRODUCT_WEB_SERVER                      0x00000011
#define PRODUCT_CLUSTER_SERVER                  0x00000012
#define PRODUCT_HOME_SERVER                     0x00000013
#define PRODUCT_STORAGE_EXPRESS_SERVER          0x00000014
#define PRODUCT_STORAGE_STANDARD_SERVER         0x00000015
#define PRODUCT_STORAGE_WORKGROUP_SERVER        0x00000016
#define PRODUCT_STORAGE_ENTERPRISE_SERVER       0x00000017
#define PRODUCT_SERVER_FOR_SMALLBUSINESS        0x00000018
#define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM    0x00000019

#define PRODUCT_UNLICENSED                      0xABCDABCD
#endif


be care... I added new define:
#define SM_SERVERR2             89

Maybe i did something wrong, but it was compiled and runed ok with all 3 compilers: MSC8, MSC9 and MINGW.
Re: Ole Automation [FEATURE REQUEST?] [message #21159 is a reply to message #21158] Wed, 06 May 2009 08:34 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello tojocky

- About gdi32.lib

I suppose that the reason of this is that I added this lib in the last sysinfo version. I probably updated in Bazaar the sources but not the upp file.


- About MSC8

Added the includes


Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21163 is a reply to message #21159] Wed, 06 May 2009 09:52 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello Koldo!

I added new methods
for classes OfficeSheet and MSSheet:
	// >>>Ion Lupascu 06.05.2009 Add this methods
	int GetSheetsCount();
	bool SetActiveSheet(int index);
	bool SetActiveSheet(String name);
	bool SetSheetName(String new_name);
	// <<<Ion Lupascu 06.05.2009


Details for MSSheet:
// >>> Ion Lupascu 06.05.2009 Add this methods
int MSSheet::GetSheetsCount(){
	if (!Book)
		return(-1);
	
	return((int)Ole::GetValue(Ole::GetObject(Book, "Sheets"), "Count"));
}

// Set active sheet start with 0(zero)
bool MSSheet::SetActiveSheet(int index){
	if(!Book)
		return false;
	
	VariantOle index_ole;
	index_ole.Int4(index + 1);
	
	if (!(Sheet = Ole::GetObject(Book, "Sheets", index_ole)))
		return false;

	return true;
}

// Set active sheet by name
bool MSSheet::SetActiveSheet(String name){
	if(!Book)
		return false;
	
	VariantOle name_ole;
	name_ole.BString(name);
	
	if (!(Sheet = Ole::GetObject(Book, "Sheets", name_ole)))
		return false;

	return true;
}

bool MSSheet::SetSheetName(String new_name){
	if(!Sheet)
		return false;
	
	VariantOle new_name_ole;
	new_name_ole.BString(new_name);
	
	return Ole::SetValue(Sheet, "Name", new_name_ole);
}
// <<< Ion Lupascu 06.05.2009


Details for OfficeSheet:
// >>> Ion Lupascu 06.05.2009 Add this methods
int OfficeSheet::GetSheetsCount(){
	if (!data)
		return -1;
	if (type == SheetOPEN)
		return -1; //... need to add ((OPENSheet*)data)->GetSheetsCount();
	else if (type == SheetMS)
		return ((MSSheet*)data)->GetSheetsCount();
	else
		return -1;
}

// Set active sheet start with 0(zero)
bool OfficeSheet::SetActiveSheet(int index){
	if (!data)
		return false;
	if (type == SheetOPEN)
		return false; //... need to add ((OPENSheet*)data)->SetActiveSheet(index);
	else if (type == SheetMS)
		return ((MSSheet*)data)->SetActiveSheet(index);
	else
		return false;
}

// Set active sheet by name
bool OfficeSheet::SetActiveSheet(String name){
	if (!data)
		return false;
	if (type == SheetOPEN)
		return false; //... need to add ((OPENSheet*)data)->SetActiveSheet(name);
	else if (type == SheetMS)
		return ((MSSheet*)data)->SetActiveSheet(name);
	else
		return false;
}

bool OfficeSheet::SetSheetName(String new_name){
	if (!data)
		return false;
	if (type == SheetOPEN)
		return false; //... need to add ((OPENSheet*)data)->SetActiveSheet(name);
	else if (type == SheetMS)
		return ((MSSheet*)data)->SetSheetName(new_name);
	else
		return false;
}
// <<< Ion Lupascu 06.05.2009


I do not added this method for Open office. Please check this and add methods for Open calc too. Maybe exists memory leak in method:
// Set active sheet by name
bool MSSheet::SetActiveSheet(String name){
	if(!Book)
		return false;
	
	VariantOle name_ole;
	name_ole.BString(name);
	
>>HERE  if (!(Sheet = Ole::GetObject(Book, "Sheets", name_ole)))
		return false;

	return true;
}


I tested this new methods and works fine!

Thank you for changes with MSC8 and gdi32.lib
Re: Ole Automation [FEATURE REQUEST?] [message #21168 is a reply to message #21163] Wed, 06 May 2009 11:52 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello Tojocky

Thank you for your effort.

Please next time tell me that you are going to implement code to avoid doing the things twice Smile. I had done almost all this morning!!!

About function naming, if you see class OPENSheet you will see:

class OPENSheet
{
...
	// New functs for next versions
	bool InsertTab(String name);
	bool ChooseTab(String name);
	bool ChooseTab(int index);
	int GetNumTabs();


These functions are already implemented in Automation.cpp for OpenOffice!!
As I did not implement them in MSOffice I did not make them visible before.

The final thing I am doing now and sometimes is the most difficult is to have just the same behaviour with OpenOffice and MSOffice implementations, as in some things they do not work the same.

Please, believe me. You have done the things well. Please next time tell me you are going to do the job before.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21169 is a reply to message #21168] Wed, 06 May 2009 12:25 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
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 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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 #21179 is a reply to message #21174] Thu, 07 May 2009 00:24 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello tojocky

I have updated in Bazaar Automation and Sysinfo.

The functions added are:

class OfficeSheet
{
public:
...
	bool InsertTab(String name);
	bool ChooseTab(String name);
	bool ChooseTab(int index);
	bool RemoveTab(String name);
	bool RemoveTab(int index);
	int GetNumTabs();
...


They support both OpenOffice Calc and Excel and have the same behaviour.


I have included in demo

sheet.SetValue(1, 2, "'123456789123456789");


This is a special case because this number is over the Calc and Excel precision, so if you want to get all the digits you have to enter it as text. For me the easiest way is just adding a ' in the beginning.

I have not found any memory leak. Try to use the new code from svn and tell me the details if you get something wrong.

Thank you for your efforts
Koldo



Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21181 is a reply to message #21179] Thu, 07 May 2009 09:18 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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 #21185 is a reply to message #17864] Thu, 07 May 2009 22:55 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello tojocky

I have had difficulties with svn. Finally it is updated in bazaar.

- About the ' symbol

I really use it in the every day spreadsheet use. For me it is faster to do it than choosing the cell, open the format menu looking for the text format and after that, enter the string.

It is simple and it works. Neither Calc/Excel nor OfficeSheet knows better than the user the real format of strings that are not clear, like:

- 123456789123456789 or
- 00123

I do not know to include your code... that is really Ok
Quote:

if(IsString(value)){
VariantOle txt_format_ole;
txt_format_ole.BString("@");

Ole::SetValue(Range, "NumberFormat", txt_format_ole);
}

as for "123456789123456789" and "123", they will be considered as text and it will not be possible to do any mathematical operation with them. This can be a source of problems.


- About SetFormatSelection

Well, something has to be done. I considered that to have less priority as:
-- I have to prepare the same interface for Calc and Excel
-- I found more interesting and easier to do cells formating with colors, more font handling and borders


They are opinions. Please tell me what are the most important format options to be included. If you plan to do something please tell me in advance so that we will not repeat the job.

Best regards
Koldo




Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21186 is a reply to message #21185] Fri, 08 May 2009 08:16 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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 #21318 is a reply to message #21186] Tue, 12 May 2009 23:12 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello Koldo!

Seems I found a little interesting project that read and write excel in direct stream file for Excel 97-2003.

http://www.codeproject.com/KB/office/BasicExcel.aspx

And other example I found in c# for excel 2007 write and read.

http://www.codeproject.com/KB/office/OpenXML.aspx

In Excel 2007 the format is more readable.
Re: Ole Automation [FEATURE REQUEST?] [message #21330 is a reply to message #21318] Wed, 13 May 2009 14:09 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
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



Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21331 is a reply to message #21330] Wed, 13 May 2009 14:38 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

People, could you please rename Automation package into, i.e. Docflow, Microsoft, or Office. "Automation" stands for many things, especially industrial automation. So "automation" IMO is much less informative and more confusing than "Docflow".
Re: Ole Automation [FEATURE REQUEST?] [message #21332 is a reply to message #21330] Wed, 13 May 2009 14:59 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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 #21337 is a reply to message #21332] Wed, 13 May 2009 23:09 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello tojocky

.doc and .xls are not documented binary formats only recognized by hacking. The only way for an average human (like me) to access them is by using a library.

Open Document and Open XML are well documented open formats. The problem is the size of these standards:

- Open Document. Standard ISO/IEC 26300. 722 pag
- Open XML. Standard ISO/IEC 29500. 7228 pages

The huge size of 722 pages seems small comparing to the 7228 pages of the microsoft standard.

I can not answer properly as I do not know them, but it seems a hard work to try to use only a small percentage of them. I repeat, I am an average person. Smile

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21345 is a reply to message #17864] Thu, 14 May 2009 08:14 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 826
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? Smile ) 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

Re: Ole Automation [FEATURE REQUEST?] [message #21362 is a reply to message #21345] Fri, 15 May 2009 14:15 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Well, I guess nobody liked the idea of renaming Automation to OleAutomation.
Re: Ole Automation [FEATURE REQUEST?] [message #21363 is a reply to message #21362] Fri, 15 May 2009 14:26 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 826
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
Mindtraveller wrote on Fri, 15 May 2009 14:15

Well, I guess nobody liked the idea of renaming Automation to OleAutomation.


I certainly do, but I'm merely passing by, it's up to others.
Re: Ole Automation [FEATURE REQUEST?] [message #21364 is a reply to message #21363] Fri, 15 May 2009 16:18 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
mr_ped wrote on Fri, 15 May 2009 14:26

Mindtraveller wrote on Fri, 15 May 2009 14:15

Well, I guess nobody liked the idea of renaming Automation to OleAutomation.


I certainly do, but I'm merely passing by, it's up to others.


Well, I put Automation name because:

- I wanted to use it also in Linux for OpenOffice through its UNO interface
- Really "Ole Automation" is the old name as Microsoft renamed the technology to simply "Automation"

I have the hope that in the next future it would be possible to interface OpenOffice in Linux so I would not add "Ole" to the package name.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21365 is a reply to message #21364] Fri, 15 May 2009 18:55 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

I`m afraid the word "Automation" has many meanings beyond plain docflow. Therefore it will be confusing for people who is not closely connected to office applications only (my first reaction was "Wow, industrial automation package for U++! Let`s look what microcontrollers are supported..."). My proposal is avoid confusion from the start and select more appropriate naming for what is really your package is doing, such as: Office (IMO the best choice), Docflow, OleAutomation, etc.
Re: Ole Automation [FEATURE REQUEST?] [message #21395 is a reply to message #17864] Mon, 18 May 2009 08:29 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 826
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
OfficeAutomation ?
Re: Ole Automation [FEATURE REQUEST?] [message #21399 is a reply to message #21395] Mon, 18 May 2009 10:23 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello mr_ped

I like it. If everybody agrees this week I would change the name next Monday.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21404 is a reply to message #21399] Mon, 18 May 2009 13:56 Go to previous messageGo to previous message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

I agree. Thank you everyone.
Previous Topic: MAPIEx works with MinGW
Next Topic: [Controls4U] IE shows script errors
Goto Forum:
  


Current Time: Tue May 05 03:14:51 GMT+2 2026

Total time taken to generate the page: 0.01658 seconds