Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » Ole Automation [FEATURE REQUEST?]
Re: Ole Automation [FEATURE REQUEST?] [message #19776 is a reply to message #17864] Sat, 17 January 2009 00:22 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3443
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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: MAPIEx works with MinGW
Next Topic: [Controls4U] IE shows script errors
Goto Forum:
  


Current Time: Sun Aug 24 04:51:50 CEST 2025

Total time taken to generate the page: 0.00671 seconds