ΠΕΡΙΚΛΗ ΘΩΙΔΗ blog

Βγάλε από την ψυχή σου λόγια να ακουστούν

Αρχεία για Ιούνιος, 2012


Delphi 5 automation OpenOffice Calc

procedure TForm0.OpenOffice(Sender: TObject);
var desktop,document, oSheet, bookmark, textRange: OleVariant;
URL:String;
allBorders, aBorder:Variant;
i, row_print:integer;
begin
// must declare serviceManager like this
//  public
//    { Public declarations }
//    serviceManager:Variant;
serviceManager:= CreateOleObject(‘com.sun.star.ServiceManager’);
desktop:= serviceManager.createInstance(‘com.sun.star.frame.Desktop’);
Url :=’file:///’+extractFilePath(FileNameEdit1.FileName)+’D24.ods’; // Template
document:=Desktop.loadComponentFromURL(Url, ‘_blank’, 0, VarArrayCreate([0, 0], VarVariant));
//  oSheet := document.getSheets.getByIndex(0); // get the zero
oSheet := document.getSheets.getByName( ‘sname’ ); // get by name
DecimalSeparator:=’.’; // for use in greek language
DataPrint.tKrat_help.close;
DataPrint.tKrat_help.sql.Clear;
DataPrint.tKrat_help.sql.Add(‘Select * from krat2000’);
DataPrint.tKrat_help.open;
oSheet.getCellRangeByName(‘D6’).setString(dataprint.tconfig.FieldByname(‘cnf_yphresia’).asstring);
oSheet.getCellRangeByName(‘D7’).setString(dataprint.tconfig.FieldByname(‘cnf_ypol’).asstring);
oSheet.getCellRangeByName(‘C9′).setString(form32.mmistos.Text+’ ‘+form32.mhnas.Text+’ ‘+main.metos);
oSheet.getCellRangeByName(‘G9’).setString(HId.Text);
row_print:=12;
oSheet.getCellRangeByName(‘A12’).setString(‘1’);
for i:=1 to num_AP do begin
if DataPrint.TsSynola.FieldByNAme(‘AP’+strZero(i,2)).ascurrency<>0 then begin
tkae_apod.locate(‘name’,DataPrint.tKrat_Help.fieldByname(‘name’).asstring,[loCaseInsensitive, loPartialKey]);
if check_kae.checked then
oSheet.getCellRangeByName(‘B’+inttostr(row_print)).setString(mKae.Text)
else begin
oSheet.getCellRangeByName(‘B’+inttostr(row_print)).setString(tKae_apod.FieldByNAme(‘kae_xml’).asstring);
end;
oSheet.getCellRangeByName(‘C’+inttostr(row_print)).setString(tKae_apod.FieldByNAme(‘print_name’).asstring);
oSheet.getCellRangeByName(‘D’+inttostr(row_print)).setValue(DataPrint.TsSynola.FieldByNAme(‘AP’+strZero(i,2)).ascurrency);
oSheet.getCellRangeByName(‘D’+inttostr(row_print)).NumberFormat:=4;  //#.##0,00
row_print:=row_print+1;
end;
end;
oSheet.getCellRangeByName(‘B’+inttostr(row_print)+’:’+’C’+inttostr(row_print)).Merge(True);
oSheet.getCellRangeByName(‘B’+inttostr(row_print)).setString(‘sumary value’);
oSheet.getCellRangeByName(‘A’+inttostr(row_print)+’:’+’D’+inttostr(row_print)).Merge(True);
oSheet.getCellRangeByName(‘D’+inttostr(row_print)).setFormula(‘=sum(D12:D’+inttostr(row_print-1)+’)’);
row_print:=row_print+1;
oSheet.getCellRangeByName(‘B’+inttostr(row_print)).setString(‘Sum Sumary’);
oSheet.getCellRangeByName(‘B’+inttostr(row_print)+’:’+’C’+inttostr(row_print)).Merge(True);
oSheet.getCellRangeByName(‘D’+inttostr(row_print)).setFormula(‘=D’+inttostr(row_print-1));
oSheet.getCellRangeByName(‘A’+inttostr(row_print)+’:’+’D’+inttostr(row_print)).CharWeight := 150; // Bold
oSheet.getCellRangeByName(‘A12:’+’A’+inttostr(row_print-1)).Merge(True);
//  procedure for drawing borders
//  procedure oo_cell_Border(ooRange:string; ooTop,ooBottom,ooLeft,ooRight,ooVertical,ooHorizontal:integer; oSheet:OLEVariant);
oo_cell_Border(‘A12:A12’,50,50,50,50,50,50,oSheet);
oo_cell_Border(‘B12:D’+inttostr(row_print),50,50,50,50,50,50,oSheet);
DecimalSeparator:=’,’; // for use in greek language
end;
procedure TForm0.oo_cell_Border(ooRange:string; ooTop,ooBottom,ooLeft,ooRight,ooVertical,ooHorizontal:integer; oSheet:OLEVariant);
Var allBorders, aBorder: Variant;
begin
allBorders := oSheet.getCellRangeByName(oorange).TableBorder;
aBorder := allBorders.TopLine;
//aBorder.Color := clBlack ;
aBorder.OuterLineWidth := ooTop;
allBorders.TopLine := aBorder;
aBorder := allBorders.BottomLine;
//aBorder.Color := clBlack ;
aBorder.OuterLineWidth := ooBottom;
allBorders.BottomLine:= aBorder;
aBorder := allBorders.LeftLine;
//aBorder.Color := clBlack ;
aBorder.OuterLineWidth := ooLeft;
allBorders.LeftLine := aBorder;
aBorder := allBorders.RightLine;
//aBorder.Color := clBlack ;
aBorder.OuterLineWidth := ooRight;
allBorders.RightLine := aBorder;
aBorder := allBorders.VerticalLine;
aBorder.Color := 0;
aBorder.OuterLineWidth := ooVertical;
allBorders.VerticalLine := aBorder;
aBorder := allBorders.HorizontalLine;
aBorder.Color := 0;
aBorder.OuterLineWidth := ooHorizontal;
allBorders.HorizontalLine := aBorder;
allBorders.IsTopLineValid := True;
allBorders.IsBottomLineValid := True;
allBorders.IsLeftLineValid := True;
allBorders.IsRightLineValid := True;
allBorders.IsVerticalLineValid := True;
allBorders.IsHorizontalLineValid := True;
oSheet.getCellRangeByName(oorange).TableBorder:= allBorders;
end;

procedure TForm0.OpenOffice(Sender: TObject);var desktop,document, oSheet, bookmark, textRange: OleVariant;    URL:String;    allBorders, aBorder:Variant;    i, row_print:integer;begin
// must declare serviceManager like this//  public//    { Public declarations }//    serviceManager:Variant;
serviceManager:= CreateOleObject(‘com.sun.star.ServiceManager’);  desktop:= serviceManager.createInstance(‘com.sun.star.frame.Desktop’);  Url :=’file:///’+extractFilePath(FileNameEdit1.FileName)+’D24.ods’; // Template  document:=Desktop.loadComponentFromURL(Url, ‘_blank’, 0, VarArrayCreate([0, 0], VarVariant));
//  oSheet := document.getSheets.getByIndex(0); // get the zero  oSheet := document.getSheets.getByName( ‘sname’ ); // get by name
DecimalSeparator:=’.’; // for use in greek language
DataPrint.tKrat_help.close;  DataPrint.tKrat_help.sql.Clear;  DataPrint.tKrat_help.sql.Add(‘Select * from krat2000’);  DataPrint.tKrat_help.open;  oSheet.getCellRangeByName(‘D6’).setString(dataprint.tconfig.FieldByname(‘cnf_yphresia’).asstring);  oSheet.getCellRangeByName(‘D7’).setString(dataprint.tconfig.FieldByname(‘cnf_ypol’).asstring);  oSheet.getCellRangeByName(‘C9′).setString(form32.mmistos.Text+’ ‘+form32.mhnas.Text+’ ‘+main.metos);  oSheet.getCellRangeByName(‘G9’).setString(HId.Text);
row_print:=12;  oSheet.getCellRangeByName(‘A12’).setString(‘1’);  for i:=1 to num_AP do begin     if DataPrint.TsSynola.FieldByNAme(‘AP’+strZero(i,2)).ascurrency<>0 then begin        tkae_apod.locate(‘name’,DataPrint.tKrat_Help.fieldByname(‘name’).asstring,[loCaseInsensitive, loPartialKey]);        if check_kae.checked then             oSheet.getCellRangeByName(‘B’+inttostr(row_print)).setString(mKae.Text)        else begin           oSheet.getCellRangeByName(‘B’+inttostr(row_print)).setString(tKae_apod.FieldByNAme(‘kae_xml’).asstring);        end;
oSheet.getCellRangeByName(‘C’+inttostr(row_print)).setString(tKae_apod.FieldByNAme(‘print_name’).asstring);        oSheet.getCellRangeByName(‘D’+inttostr(row_print)).setValue(DataPrint.TsSynola.FieldByNAme(‘AP’+strZero(i,2)).ascurrency);        oSheet.getCellRangeByName(‘D’+inttostr(row_print)).NumberFormat:=4;  //#.##0,00        row_print:=row_print+1;     end;  end;  oSheet.getCellRangeByName(‘B’+inttostr(row_print)+’:’+’C’+inttostr(row_print)).Merge(True);  oSheet.getCellRangeByName(‘B’+inttostr(row_print)).setString(‘sumary value’);  oSheet.getCellRangeByName(‘A’+inttostr(row_print)+’:’+’D’+inttostr(row_print)).Merge(True);  oSheet.getCellRangeByName(‘D’+inttostr(row_print)).setFormula(‘=sum(D12:D’+inttostr(row_print-1)+’)’);  row_print:=row_print+1;
oSheet.getCellRangeByName(‘B’+inttostr(row_print)).setString(‘Sum Sumary’);  oSheet.getCellRangeByName(‘B’+inttostr(row_print)+’:’+’C’+inttostr(row_print)).Merge(True);  oSheet.getCellRangeByName(‘D’+inttostr(row_print)).setFormula(‘=D’+inttostr(row_print-1));  oSheet.getCellRangeByName(‘A’+inttostr(row_print)+’:’+’D’+inttostr(row_print)).CharWeight := 150; // Bold
oSheet.getCellRangeByName(‘A12:’+’A’+inttostr(row_print-1)).Merge(True);    //  procedure for drawing borders  //  procedure oo_cell_Border(ooRange:string; ooTop,ooBottom,ooLeft,ooRight,ooVertical,ooHorizontal:integer; oSheet:OLEVariant);  oo_cell_Border(‘A12:A12’,50,50,50,50,50,50,oSheet);     oo_cell_Border(‘B12:D’+inttostr(row_print),50,50,50,50,50,50,oSheet);

DecimalSeparator:=’,’; // for use in greek language
end;
procedure TForm0.oo_cell_Border(ooRange:string; ooTop,ooBottom,ooLeft,ooRight,ooVertical,ooHorizontal:integer; oSheet:OLEVariant);Var allBorders, aBorder: Variant;
begin  allBorders := oSheet.getCellRangeByName(oorange).TableBorder;
aBorder := allBorders.TopLine;  //aBorder.Color := clBlack ;  aBorder.OuterLineWidth := ooTop;  allBorders.TopLine := aBorder;
aBorder := allBorders.BottomLine;  //aBorder.Color := clBlack ;  aBorder.OuterLineWidth := ooBottom;  allBorders.BottomLine:= aBorder;
aBorder := allBorders.LeftLine;  //aBorder.Color := clBlack ;  aBorder.OuterLineWidth := ooLeft;  allBorders.LeftLine := aBorder;
aBorder := allBorders.RightLine;  //aBorder.Color := clBlack ;  aBorder.OuterLineWidth := ooRight;  allBorders.RightLine := aBorder;
aBorder := allBorders.VerticalLine;  aBorder.Color := 0;  aBorder.OuterLineWidth := ooVertical;  allBorders.VerticalLine := aBorder;
aBorder := allBorders.HorizontalLine;  aBorder.Color := 0;  aBorder.OuterLineWidth := ooHorizontal;  allBorders.HorizontalLine := aBorder;
allBorders.IsTopLineValid := True;  allBorders.IsBottomLineValid := True;  allBorders.IsLeftLineValid := True;  allBorders.IsRightLineValid := True;  allBorders.IsVerticalLineValid := True;  allBorders.IsHorizontalLineValid := True;
oSheet.getCellRangeByName(oorange).TableBorder:= allBorders;end;


Αλλαγή μεγέθους γραμματοσειράς
Αντίθεση
Μετάβαση σε γραμμή εργαλείων