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

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

Αρχεία για ‘Delphi’


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;

Αλγόριθμος Ελέγχου ΑΜΚΑ

Ψάχνοντας για τον αλγόριθμο ελέγχου ορθότητα του ΑΜΚΑ βρήκα τον παρακάτω αλγόριθμο  τον εφάρμοσα  και δείχνει να δουλεύει άψογα.

2.1 Attachment Control Number (ACN) Check Digit Example
ID = 49927398716
The ACN consists of 11 numeric digits, with the last being the check digit.
Step 1:

4 9 9 2 7 3 9 8 7 1 6
x 2 x 2 x 2 x 2 x 2
18 4 6 16 2

Step 2:
4 + (1+8) + 9 + (4) + 7 + (6) + 9 + (1+6) + 7 + (2) + 6
Result: Sum = 70: The number is valid.
Note: The number is valid because 70 divided by 10 yields no remainder
(70 mod 10 = 0).


Προγραμματισμός σε Delphi

Έχεις κάποια απορία σχετικά με κώδικα σε Delphi, ίσως μπορώ να βοηθήσω !!!


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