Migration XLSRW 4 to 5

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
Armagedoon
Posts: 1
Joined: Fri Jan 16, 2015 10:01 am

Migration XLSRW 4 to 5

Post by Armagedoon »

Helo Lars!
go to version 5 and part of the code does not work (highlighted in red)

procedure TFlot.btn2Click(Sender: TObject);
var
CRow, mn, mk, i : Integer;
FN : string;
mnt : array[1..12] of string;
begin
OD.FilterIndex := 1;
if OD.Execute then
begin
fn := OD.FileName;
XLS.Filename := fn;
XLS.Read;
XLS.Sheets[0].DeleteRows(10, 500);
XLS.CopyColumns(1, 0, 17, 0, 0);

CRow := 10;

DM.GKPZU.Active := False;
DM.GKPZU.Active := True;
mnt[1] := 'Январь';
mnt[2] := 'Февраль';
mnt[3] := 'Март';
mnt[4] := 'Апрель';
mnt[5] := 'Май';
mnt[6] := 'Июнь';
mnt[7] := 'Июль';
mnt[8] := 'Август';
mnt[9] := 'Сентябрь';
mnt[10] := 'Октябрь';
mnt[11] := 'Ноябрь';
mnt[12] := 'Декабрь';
DM.GKPZU.First;
P3.Max := DM.GKPZU.RecordCount;
while not DM.GKPZU.Eof do
begin
P3.Position := DM.GKPZU.RecNo;
if DM.GKPZU.FieldList.Fields[0].AsInteger<>0 then
begin
for I := 14 downto 3 do if DM.GKPZU.FieldList.Fields.AsFloat>0 then mn := i-2;
for I := 3 to 14 do if DM.GKPZU.FieldList.Fields.AsFloat>0 then mk := i-2;
XLS.Sheets[0].AsString[0, CRow] := '3.1';
XLS.Sheets[0].AsString[1, CRow] := 'ХГРЭС';
XLS.Sheets[0].AsInteger[2, CRow] := DM.GKPZU.FieldList.Fields[0].AsInteger;
XLS.Sheets[0].AsInteger[3, CRow] := 1;
XLS.Sheets[0].AsString[4, CRow] := DM.GKPZU.FieldList.Fields[15].AsString;
XLS.Sheets[0].AsString[7, CRow] := 'Себестоимость (ремонтный фонд)';
XLS.Sheets[0].AsFloat[8, CRow] := RoundTo((DM.GKPZU.FieldList.Fields[1].AsFloat+DM.GKPZU.FieldList.Fields[2].AsFloat)/1000, -2);
XLS.Sheets[0].AsString[9, CRow] := '2009';
XLS.Sheets[0].AsString[10, CRow] := mnt[mn];
XLS.Sheets[0].AsString[11, CRow] := '2009';
XLS.Sheets[0].AsString[12, CRow] := mnt[mk];
XLS.Sheets[0].AsString[13, CRow] := 'ХГРЭС';
XLS.Sheets[0].AsString[17, CRow] := DM.GKPZU.FieldList.Fields[16].AsString;
XLS.Sheets[0].Range.Items[0, cRow, 17, cRow].FormatOptions :=[foWrapText];
XLS.Sheets[0].Range.Items[0, cRow, 17, cRow].BorderOutlineStyle := cbsThin;
XLS.Sheets[0].Range.Items[0, cRow, 17, cRow].BorderInsideVertStyle := cbsThin;

Inc(CRow);
end;
DM.GKPZU.Next;
end;
P3.Position := 0;
xls.Sheets[0].SheetProtection:=[spEditObjects,spEditScenarios,
spEditCellFormatting,spEditColumnFormatting,spEditRowFormatting,
spInsertColumns,spInsertRows,spInsertHyperlinks,spDeleteColumns,
spDeleteRows,spSelectLockedCells,spSortCellRange,spEditAutoFileters,
spEditPivotTables,spSelectUnlockedCells];

XLS.Write;
end;


please help :roll: :roll:
Post Reply