Calc představuje tabulkový kalkulátor. Ten je součástí kancelářského balíku OpenOffice a LibreOffice a je alternativou k programu Microsoft Excel. Používá se pro tvorbu tabulek, ale také pro komplexní soustavy propojených dat se vzorci a funkcemi. Tabulka je ukládána v novém mezinárodním standardu pro dokumenty. Je založen na XML a může být přečten i tehdy, když uživatel nemá OpenOffice nebo LibreOffice. Výchozím formátem pro tabulky Calc je soubor *.ods.
function onClose()
{
oDoc.Close(false);
}
var oSM, oCR, oDesk, oDoc, oSh, oSheet, oCell, s, sPath, sFilePath, bDone;
var jArr = Pm.CreatePmArray().Create(1);
var args = jArr.SaveToVbArray();
var arg = jArr.SaveToVbArray();
sPath = Pm.DiscGetPath("data:");
s = Pm.StringReplace(sPath, "\\", "/");
sFilePath = s + "test2.ods";
//The service manager is always the starting point
//If there is no office running then an office is started up
oSM = Pm.AxGetObject("new", "com.sun.star.ServiceManager");
//Create the CoreReflection service that is later used to create structs
oCR = oSM.createInstance("com.sun.star.reflection.CoreReflection");
//Create the Desktop
oDesk = oSM.createInstance("com.sun.star.frame.Desktop");
//Open a new empty calc document
oDoc = oDesk.loadComponentFromURL("private:factory/scalc", "_blank", 0, args);
//Create a sheet object
oSh = oDoc.getSheets();
oSheet = oSh.GetByIndex(0);
oCell = oSheet.getCellByPosition(0, 0);
oCell.String = "A col";
oCell.CellBackColor = 6710932;
oCell = oSheet.getCellByPosition(1, 0);
oCell.String = "B col";
oCell.CellBackColor = 6710932;
oCell = oSheet.getCellByPosition(2, 0);
oCell.String = "C col";
oCell.CellBackColor = 6710932;
oSheet.getCellByPosition(0, 1).Value = 123;
oSheet.getCellByPosition(1, 1).Value = 222;
oSheet.getCellByPosition(2, 1).Value = 333;
bDone = oDoc.storeAsURL("file:///" + sFilePath, arg);
pMe.Root.AddEventTimer(2000, 1, onClose);
function onClose()
{
oDoc.Close(false);
}
var oSM, oCR, oDesk, oDoc, oSh, oSheet, oCell, s, sPath, sFilePath, bDone;
var jArr = Pm.CreatePmArray().Create(1);
var args = jArr.SaveToVbArray();
var arg = jArr.SaveToVbArray();
sPath = Pm.EvalMacro("$path.data:");
s = Pm.StringReplace(sPath, "\\", "/");
sFilePath = s + "test2.ods";
//The service manager is always the starting point
//If there is no office running then an office is started up
oSM = Pm.AxGetObject("new", "com.sun.star.ServiceManager");
//Create the CoreReflection service that is later used to create structs
oCR = oSM.createInstance("com.sun.star.reflection.CoreReflection");
//Create the Desktop
oDesk = oSM.createInstance("com.sun.star.frame.Desktop");
//Open calc document
oDoc = oDesk.loadComponentFromURL("file:///" + sFilePath, "_blank", 0, args);
//Create a sheet object
oSh = oDoc.getSheets();
oSheet = oSh.GetByIndex(0);
oSheet.getCellByPosition(0, 2).Value = 375;
oSheet.getCellByPosition(1, 2).Value = Pm.Round(Pm.Random(0, 100), 0.1);
oSheet.getCellByPosition(2, 2).Value = Pm.Round(Pm.Random(0, 100), 0.1);
bDone = oDoc.storeAsURL("file:///" + sFilePath, arg);
pMe.Root.AddEventTimer(2000, 1, onClose);