You've already forked lazarus-ccr
fpspreadsheet: tests: get empty temp file just before wrtiing out. Coding style: do begin matches initial style+FPC coding style.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3336 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -302,7 +302,7 @@ var
|
|||||||
Row: Cardinal;
|
Row: Cardinal;
|
||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
begin
|
begin
|
||||||
TempFile:=GetTempFileName;
|
TempFile:=NewTempFile;
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -372,8 +372,7 @@ var
|
|||||||
ActualDateTime: TDateTime;
|
ActualDateTime: TDateTime;
|
||||||
ErrorMargin: TDateTime; //margin for error in comparison test
|
ErrorMargin: TDateTime; //margin for error in comparison test
|
||||||
begin
|
begin
|
||||||
//ErrorMargin:=0.000000000000001; // = 1E-15 = 9E-11 sec
|
ErrorMargin := 1E-5/(24*60*60*1000); // = 10 nsec = 1E-8 sec (1 ns fails)
|
||||||
ErrorMargin := 1E-5/(24*60*60*1000); // = 10 nsec = 1E-8 sec // 1 ns fails
|
|
||||||
if Row>High(SollDates) then
|
if Row>High(SollDates) then
|
||||||
fail('Error in test code: array bounds overflow. Check array size is correct.');
|
fail('Error in test code: array bounds overflow. Check array size is correct.');
|
||||||
|
|
||||||
|
@ -132,7 +132,6 @@ var
|
|||||||
MyCell: PCell;
|
MyCell: PCell;
|
||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
begin
|
begin
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -160,6 +159,7 @@ begin
|
|||||||
CheckEquals(uffBold in MyCell^.UsedFormattingFields, true,
|
CheckEquals(uffBold in MyCell^.UsedFormattingFields, true,
|
||||||
'Test unsaved bold attribute, cell '+CellNotation(MyWorksheet,Row, Col));
|
'Test unsaved bold attribute, cell '+CellNotation(MyWorksheet,Row, Col));
|
||||||
|
|
||||||
|
TempFile:=NewTempFile;
|
||||||
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ var
|
|||||||
expectedValue: String;
|
expectedValue: String;
|
||||||
counter: Integer;
|
counter: Integer;
|
||||||
begin
|
begin
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -237,8 +237,10 @@ begin
|
|||||||
MyWorkSheet:= MyWorkBook.AddWorksheet(FontSheet);
|
MyWorkSheet:= MyWorkBook.AddWorksheet(FontSheet);
|
||||||
|
|
||||||
// Write out all font styles at various sizes
|
// Write out all font styles at various sizes
|
||||||
for row := 0 to High(SollSizes) do begin
|
for row := 0 to High(SollSizes) do
|
||||||
for col := 0 to High(SollStyles) do begin
|
begin
|
||||||
|
for col := 0 to High(SollStyles) do
|
||||||
|
begin
|
||||||
cellText := Format('%s, %.1f-pt', [AFontName, SollSizes[row]]);
|
cellText := Format('%s, %.1f-pt', [AFontName, SollSizes[row]]);
|
||||||
MyWorksheet.WriteUTF8Text(row, col, celltext);
|
MyWorksheet.WriteUTF8Text(row, col, celltext);
|
||||||
MyWorksheet.WriteFont(row, col, AFontName, SollSizes[row], SollStyles[col], scBlack);
|
MyWorksheet.WriteFont(row, col, AFontName, SollSizes[row], SollStyles[col], scBlack);
|
||||||
@ -255,6 +257,7 @@ begin
|
|||||||
'Test unsaved font style, cell ' + CellNotation(MyWorksheet,0,0));
|
'Test unsaved font style, cell ' + CellNotation(MyWorksheet,0,0));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
TempFile:=NewTempFile;
|
||||||
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
@ -269,7 +272,8 @@ begin
|
|||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
counter := 0;
|
counter := 0;
|
||||||
for row := 0 to MyWorksheet.GetLastRowIndex do
|
for row := 0 to MyWorksheet.GetLastRowIndex do
|
||||||
for col := 0 to MyWorksheet.GetLastColIndex do begin
|
for col := 0 to MyWorksheet.GetLastColIndex do
|
||||||
|
begin
|
||||||
if (AFormat = sfExcel2) and (counter = 4) then
|
if (AFormat = sfExcel2) and (counter = 4) then
|
||||||
break; // Excel 2 allows only 4 fonts
|
break; // Excel 2 allows only 4 fonts
|
||||||
MyCell := MyWorksheet.FindCell(row, col);
|
MyCell := MyWorksheet.FindCell(row, col);
|
||||||
|
@ -165,7 +165,8 @@ begin
|
|||||||
SollNumberFormats[6] := nfPercentage; SollNumberDecimals[6] := 0;
|
SollNumberFormats[6] := nfPercentage; SollNumberDecimals[6] := 0;
|
||||||
SollNumberFormats[7] := nfPercentage; SollNumberDecimals[7] := 2;
|
SollNumberFormats[7] := nfPercentage; SollNumberDecimals[7] := 2;
|
||||||
|
|
||||||
for i:=Low(SollNumbers) to High(SollNumbers) do begin
|
for i:=Low(SollNumbers) to High(SollNumbers) do
|
||||||
|
begin
|
||||||
SollNumberStrings[i, 0] := FloatToStr(SollNumbers[i], fs);
|
SollNumberStrings[i, 0] := FloatToStr(SollNumbers[i], fs);
|
||||||
SollNumberStrings[i, 1] := FormatFloat('0', SollNumbers[i], fs);
|
SollNumberStrings[i, 1] := FormatFloat('0', SollNumbers[i], fs);
|
||||||
SollNumberStrings[i, 2] := FormatFloat('0.00', SollNumbers[i], fs);
|
SollNumberStrings[i, 2] := FormatFloat('0.00', SollNumbers[i], fs);
|
||||||
@ -194,7 +195,8 @@ begin
|
|||||||
SollDateTimeFormats[8] := nfCustom; SollDateTimeFormatStrings[8] := 'nn:ss';
|
SollDateTimeFormats[8] := nfCustom; SollDateTimeFormatStrings[8] := 'nn:ss';
|
||||||
SollDateTimeFormats[9] := nfTimeInterval; SollDateTimeFormatStrings[9] := '';
|
SollDateTimeFormats[9] := nfTimeInterval; SollDateTimeFormatStrings[9] := '';
|
||||||
|
|
||||||
for i:=Low(SollDateTimes) to High(SollDateTimes) do begin
|
for i:=Low(SollDateTimes) to High(SollDateTimes) do
|
||||||
|
begin
|
||||||
SollDateTimeStrings[i, 0] := DateToStr(SollDateTimes[i], fs) + ' ' + FormatDateTime('t', SollDateTimes[i], fs);
|
SollDateTimeStrings[i, 0] := DateToStr(SollDateTimes[i], fs) + ' ' + FormatDateTime('t', SollDateTimes[i], fs);
|
||||||
SollDateTimeStrings[i, 1] := DateToStr(SollDateTimes[i], fs);
|
SollDateTimeStrings[i, 1] := DateToStr(SollDateTimes[i], fs);
|
||||||
SollDateTimeStrings[i, 2] := FormatDateTime(fs.ShortTimeFormat, SollDateTimes[i], fs);
|
SollDateTimeStrings[i, 2] := FormatDateTime(fs.ShortTimeFormat, SollDateTimes[i], fs);
|
||||||
@ -274,7 +276,6 @@ var
|
|||||||
Row, Col: Integer;
|
Row, Col: Integer;
|
||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
begin
|
begin
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -283,11 +284,13 @@ begin
|
|||||||
MyWorkbook := TsWorkbook.Create;
|
MyWorkbook := TsWorkbook.Create;
|
||||||
MyWorkSheet:= MyWorkBook.AddWorksheet(FmtNumbersSheet);
|
MyWorkSheet:= MyWorkBook.AddWorksheet(FmtNumbersSheet);
|
||||||
for Row := Low(SollNumbers) to High(SollNumbers) do
|
for Row := Low(SollNumbers) to High(SollNumbers) do
|
||||||
for Col := ord(Low(SollNumberFormats)) to ord(High(SollNumberFormats)) do begin
|
for Col := ord(Low(SollNumberFormats)) to ord(High(SollNumberFormats)) do
|
||||||
|
begin
|
||||||
MyWorksheet.WriteNumber(Row, Col, SollNumbers[Row], SollNumberFormats[Col], SollNumberDecimals[Col]);
|
MyWorksheet.WriteNumber(Row, Col, SollNumbers[Row], SollNumberFormats[Col], SollNumberDecimals[Col]);
|
||||||
ActualString := MyWorksheet.ReadAsUTF8Text(Row, Col);
|
ActualString := MyWorksheet.ReadAsUTF8Text(Row, Col);
|
||||||
CheckEquals(SollNumberStrings[Row, Col], ActualString, 'Test unsaved string mismatch cell ' + CellNotation(MyWorksheet,Row,Col));
|
CheckEquals(SollNumberStrings[Row, Col], ActualString, 'Test unsaved string mismatch cell ' + CellNotation(MyWorksheet,Row,Col));
|
||||||
end;
|
end;
|
||||||
|
TempFile:=NewTempFile;
|
||||||
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
@ -301,7 +304,8 @@ begin
|
|||||||
if MyWorksheet=nil then
|
if MyWorksheet=nil then
|
||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
for Row := Low(SollNumbers) to High(SollNumbers) do
|
for Row := Low(SollNumbers) to High(SollNumbers) do
|
||||||
for Col := Low(SollNumberFormats) to High(SollNumberFormats) do begin
|
for Col := Low(SollNumberFormats) to High(SollNumberFormats) do
|
||||||
|
begin
|
||||||
ActualString := MyWorkSheet.ReadAsUTF8Text(Row,Col);
|
ActualString := MyWorkSheet.ReadAsUTF8Text(Row,Col);
|
||||||
CheckEquals(SollNumberStrings[Row,Col],ActualString,'Test saved string mismatch cell '+CellNotation(MyWorkSheet,Row,Col));
|
CheckEquals(SollNumberStrings[Row,Col],ActualString,'Test saved string mismatch cell '+CellNotation(MyWorkSheet,Row,Col));
|
||||||
end;
|
end;
|
||||||
@ -338,12 +342,12 @@ var
|
|||||||
Row,Col: Integer;
|
Row,Col: Integer;
|
||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
begin
|
begin
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
// Write out all test values
|
// Write out all test values
|
||||||
MyWorkbook := TsWorkbook.Create;
|
MyWorkbook := TsWorkbook.Create;
|
||||||
MyWorksheet := MyWorkbook.AddWorksheet(FmtDateTimesSheet);
|
MyWorksheet := MyWorkbook.AddWorksheet(FmtDateTimesSheet);
|
||||||
for Row := Low(SollDateTimes) to High(SollDateTimes) do
|
for Row := Low(SollDateTimes) to High(SollDateTimes) do
|
||||||
for Col := Low(SollDateTimeFormats) to High(SollDateTimeFormats) do begin
|
for Col := Low(SollDateTimeFormats) to High(SollDateTimeFormats) do
|
||||||
|
begin
|
||||||
if (AFormat = sfExcel2) and (SollDateTimeFormats[Col] in [nfCustom, nfTimeInterval]) then
|
if (AFormat = sfExcel2) and (SollDateTimeFormats[Col] in [nfCustom, nfTimeInterval]) then
|
||||||
Continue; // The formats nfFmtDateTime and nfTimeInterval are not supported by BIFF2
|
Continue; // The formats nfFmtDateTime and nfTimeInterval are not supported by BIFF2
|
||||||
MyWorksheet.WriteDateTime(Row, Col, SollDateTimes[Row], SollDateTimeFormats[Col], SollDateTimeFormatStrings[Col]);
|
MyWorksheet.WriteDateTime(Row, Col, SollDateTimes[Row], SollDateTimeFormats[Col], SollDateTimeFormatStrings[Col]);
|
||||||
@ -354,6 +358,7 @@ begin
|
|||||||
'Test unsaved string mismatch cell ' + CellNotation(MyWorksheet,Row,Col)
|
'Test unsaved string mismatch cell ' + CellNotation(MyWorksheet,Row,Col)
|
||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
|
TempFile:=NewTempFile;
|
||||||
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
@ -367,7 +372,8 @@ begin
|
|||||||
if MyWorksheet = nil then
|
if MyWorksheet = nil then
|
||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
for Row := Low(SollDateTimes) to High(SollDateTimes) do
|
for Row := Low(SollDateTimes) to High(SollDateTimes) do
|
||||||
for Col := Low(SollDateTimeFormats) to High(SollDateTimeFormats) do begin
|
for Col := Low(SollDateTimeFormats) to High(SollDateTimeFormats) do
|
||||||
|
begin
|
||||||
if (AFormat = sfExcel2) and (SollDateTimeFormats[Col] in [nfCustom, nfTimeInterval]) then
|
if (AFormat = sfExcel2) and (SollDateTimeFormats[Col] in [nfCustom, nfTimeInterval]) then
|
||||||
Continue; // The formats nfFmtDateTime and nfTimeInterval are not supported by BIFF2
|
Continue; // The formats nfFmtDateTime and nfTimeInterval are not supported by BIFF2
|
||||||
ActualString := MyWorksheet.ReadAsUTF8Text(Row,Col);
|
ActualString := MyWorksheet.ReadAsUTF8Text(Row,Col);
|
||||||
@ -414,7 +420,6 @@ var
|
|||||||
MyCell: PCell;
|
MyCell: PCell;
|
||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
begin
|
begin
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -424,9 +429,11 @@ begin
|
|||||||
MyWorkSheet:= MyWorkBook.AddWorksheet(AlignmentSheet);
|
MyWorkSheet:= MyWorkBook.AddWorksheet(AlignmentSheet);
|
||||||
|
|
||||||
row := 0;
|
row := 0;
|
||||||
for horAlign in TsHorAlignment do begin
|
for horAlign in TsHorAlignment do
|
||||||
|
begin
|
||||||
col := 0;
|
col := 0;
|
||||||
if AFormat = sfExcel2 then begin
|
if AFormat = sfExcel2 then
|
||||||
|
begin
|
||||||
// BIFF2 can only do horizontal alignment --> no need for vertical alignment.
|
// BIFF2 can only do horizontal alignment --> no need for vertical alignment.
|
||||||
MyWorksheet.WriteUTF8Text(row, col, CELLTEXT);
|
MyWorksheet.WriteUTF8Text(row, col, CELLTEXT);
|
||||||
MyWorksheet.WriteHorAlignment(row, col, horAlign);
|
MyWorksheet.WriteHorAlignment(row, col, horAlign);
|
||||||
@ -435,8 +442,10 @@ begin
|
|||||||
fail('Error in test code. Failed to get cell.');
|
fail('Error in test code. Failed to get cell.');
|
||||||
CheckEquals(ord(horAlign), ord(MyCell^.HorAlignment),
|
CheckEquals(ord(horAlign), ord(MyCell^.HorAlignment),
|
||||||
'Test unsaved horizontal alignment, cell ' + CellNotation(MyWorksheet,0,0));
|
'Test unsaved horizontal alignment, cell ' + CellNotation(MyWorksheet,0,0));
|
||||||
end else
|
end
|
||||||
for vertAlign in TsVertAlignment do begin
|
else
|
||||||
|
for vertAlign in TsVertAlignment do
|
||||||
|
begin
|
||||||
MyWorksheet.WriteUTF8Text(row, col, CELLTEXT);
|
MyWorksheet.WriteUTF8Text(row, col, CELLTEXT);
|
||||||
MyWorksheet.WriteHorAlignment(row, col, horAlign);
|
MyWorksheet.WriteHorAlignment(row, col, horAlign);
|
||||||
MyWorksheet.WriteVertAlignment(row, col, vertAlign);
|
MyWorksheet.WriteVertAlignment(row, col, vertAlign);
|
||||||
@ -451,6 +460,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
inc(row);
|
inc(row);
|
||||||
end;
|
end;
|
||||||
|
TempFile:=NewTempFile;
|
||||||
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
@ -461,7 +471,8 @@ begin
|
|||||||
MyWorksheet := MyWorkbook.GetFirstWorksheet;
|
MyWorksheet := MyWorkbook.GetFirstWorksheet;
|
||||||
if MyWorksheet=nil then
|
if MyWorksheet=nil then
|
||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
for row :=0 to MyWorksheet.GetLastRowIndex do begin
|
for row :=0 to MyWorksheet.GetLastRowIndex do
|
||||||
|
begin
|
||||||
MyCell := MyWorksheet.FindCell(row, col);
|
MyCell := MyWorksheet.FindCell(row, col);
|
||||||
if MyCell = nil then
|
if MyCell = nil then
|
||||||
fail('Error in test code. Failed to get cell.');
|
fail('Error in test code. Failed to get cell.');
|
||||||
@ -475,7 +486,8 @@ begin
|
|||||||
if MyWorksheet=nil then
|
if MyWorksheet=nil then
|
||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
for row :=0 to MyWorksheet.GetLastRowIndex do
|
for row :=0 to MyWorksheet.GetLastRowIndex do
|
||||||
for col := 0 to MyWorksheet.GetlastColIndex do begin
|
for col := 0 to MyWorksheet.GetlastColIndex do
|
||||||
|
begin
|
||||||
MyCell := MyWorksheet.FindCell(row, col);
|
MyCell := MyWorksheet.FindCell(row, col);
|
||||||
if MyCell = nil then
|
if MyCell = nil then
|
||||||
fail('Error in test code. Failed to get cell.');
|
fail('Error in test code. Failed to get cell.');
|
||||||
@ -530,7 +542,6 @@ var
|
|||||||
current: String;
|
current: String;
|
||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
begin
|
begin
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -538,12 +549,14 @@ begin
|
|||||||
// Write out all test values
|
// Write out all test values
|
||||||
MyWorkbook := TsWorkbook.Create;
|
MyWorkbook := TsWorkbook.Create;
|
||||||
MyWorkSheet:= MyWorkBook.AddWorksheet(BordersSheet);
|
MyWorkSheet:= MyWorkBook.AddWorksheet(BordersSheet);
|
||||||
for col := Low(SollBorders) to High(SollBorders) do begin
|
for col := Low(SollBorders) to High(SollBorders) do
|
||||||
|
begin
|
||||||
MyWorksheet.WriteUsedFormatting(row, col, [uffBorder]);
|
MyWorksheet.WriteUsedFormatting(row, col, [uffBorder]);
|
||||||
MyCell := MyWorksheet.GetCell(row, col);
|
MyCell := MyWorksheet.GetCell(row, col);
|
||||||
Include(MyCell^.UsedFormattingFields, uffBorder);
|
Include(MyCell^.UsedFormattingFields, uffBorder);
|
||||||
MyCell^.Border := SollBorders[col];
|
MyCell^.Border := SollBorders[col];
|
||||||
end;
|
end;
|
||||||
|
TempFile:=NewTempFile;
|
||||||
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
@ -556,7 +569,8 @@ begin
|
|||||||
MyWorksheet := GetWorksheetByName(MyWorkBook, BordersSheet);
|
MyWorksheet := GetWorksheetByName(MyWorkBook, BordersSheet);
|
||||||
if MyWorksheet=nil then
|
if MyWorksheet=nil then
|
||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
for col := 0 to MyWorksheet.GetLastColIndex do begin
|
for col := 0 to MyWorksheet.GetLastColIndex do
|
||||||
|
begin
|
||||||
MyCell := MyWorksheet.FindCell(row, col);
|
MyCell := MyWorksheet.FindCell(row, col);
|
||||||
if MyCell = nil then
|
if MyCell = nil then
|
||||||
fail('Error in test code. Failed to get cell');
|
fail('Error in test code. Failed to get cell');
|
||||||
@ -611,7 +625,6 @@ var
|
|||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
c, ls: Integer;
|
c, ls: Integer;
|
||||||
begin
|
begin
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -622,14 +635,18 @@ begin
|
|||||||
|
|
||||||
c := 0;
|
c := 0;
|
||||||
ls := 0;
|
ls := 0;
|
||||||
for row := 1 to 10 do begin
|
for row := 1 to 10 do
|
||||||
for col := 1 to 10 do begin
|
begin
|
||||||
|
for col := 1 to 10 do
|
||||||
|
begin
|
||||||
MyWorksheet.WriteBorders(row*2, col*2, [cbNorth, cbSouth, cbEast, cbWest]);
|
MyWorksheet.WriteBorders(row*2, col*2, [cbNorth, cbSouth, cbEast, cbWest]);
|
||||||
for b in TsCellBorders do begin
|
for b in TsCellBorders do
|
||||||
|
begin
|
||||||
MyWorksheet.WriteBorderLineStyle(row*2, col*2, b, SollBorderLineStyles[ls]);
|
MyWorksheet.WriteBorderLineStyle(row*2, col*2, b, SollBorderLineStyles[ls]);
|
||||||
MyWorksheet.WriteBorderColor(row*2, col*2, b, SollBorderColors[c]);
|
MyWorksheet.WriteBorderColor(row*2, col*2, b, SollBorderColors[c]);
|
||||||
inc(ls);
|
inc(ls);
|
||||||
if ls > High(SollBorderLineStyles) then begin
|
if ls > High(SollBorderLineStyles) then
|
||||||
|
begin
|
||||||
ls := 0;
|
ls := 0;
|
||||||
inc(c);
|
inc(c);
|
||||||
if c > High(SollBorderColors) then
|
if c > High(SollBorderColors) then
|
||||||
@ -638,7 +655,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
TempFile:=NewTempFile;
|
||||||
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
@ -653,12 +670,15 @@ begin
|
|||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
c := 0;
|
c := 0;
|
||||||
ls := 0;
|
ls := 0;
|
||||||
for row := 1 to 10 do begin
|
for row := 1 to 10 do
|
||||||
for col := 1 to 10 do begin
|
begin
|
||||||
|
for col := 1 to 10 do
|
||||||
|
begin
|
||||||
MyCell := MyWorksheet.FindCell(row*2, col*2);
|
MyCell := MyWorksheet.FindCell(row*2, col*2);
|
||||||
if myCell = nil then
|
if myCell = nil then
|
||||||
fail('Error in test code. Failed to get cell.');
|
fail('Error in test code. Failed to get cell.');
|
||||||
for b in TsCellBorder do begin
|
for b in TsCellBorder do
|
||||||
|
begin
|
||||||
current := ord(MyCell^.BorderStyles[b].LineStyle);
|
current := ord(MyCell^.BorderStyles[b].LineStyle);
|
||||||
expected := ord(SollBorderLineStyles[ls]);
|
expected := ord(SollBorderLineStyles[ls]);
|
||||||
CheckEquals(expected, current,
|
CheckEquals(expected, current,
|
||||||
@ -712,7 +732,6 @@ var
|
|||||||
lCol: TCol;
|
lCol: TCol;
|
||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
begin
|
begin
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -720,11 +739,13 @@ begin
|
|||||||
// Write out all test values
|
// Write out all test values
|
||||||
MyWorkbook := TsWorkbook.Create;
|
MyWorkbook := TsWorkbook.Create;
|
||||||
MyWorkSheet:= MyWorkBook.AddWorksheet(ColWidthSheet);
|
MyWorkSheet:= MyWorkBook.AddWorksheet(ColWidthSheet);
|
||||||
for Col := Low(SollColWidths) to High(SollColWidths) do begin
|
for Col := Low(SollColWidths) to High(SollColWidths) do
|
||||||
|
begin
|
||||||
lCol.Width := SollColWidths[Col];
|
lCol.Width := SollColWidths[Col];
|
||||||
//MyWorksheet.WriteNumber(0, Col, 1);
|
//MyWorksheet.WriteNumber(0, Col, 1);
|
||||||
MyWorksheet.WriteColInfo(Col, lCol);
|
MyWorksheet.WriteColInfo(Col, lCol);
|
||||||
end;
|
end;
|
||||||
|
TempFile:=NewTempFile;
|
||||||
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
@ -737,7 +758,8 @@ begin
|
|||||||
MyWorksheet := GetWorksheetByName(MyWorkBook, ColWidthSheet);
|
MyWorksheet := GetWorksheetByName(MyWorkBook, ColWidthSheet);
|
||||||
if MyWorksheet=nil then
|
if MyWorksheet=nil then
|
||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
for Col := Low(SollColWidths) to High(SollColWidths) do begin
|
for Col := Low(SollColWidths) to High(SollColWidths) do
|
||||||
|
begin
|
||||||
lpCol := MyWorksheet.GetCol(Col);
|
lpCol := MyWorksheet.GetCol(Col);
|
||||||
if lpCol = nil then
|
if lpCol = nil then
|
||||||
fail('Error in test code. Failed to return saved column width');
|
fail('Error in test code. Failed to return saved column width');
|
||||||
@ -782,7 +804,6 @@ var
|
|||||||
Row: Integer;
|
Row: Integer;
|
||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
begin
|
begin
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -792,6 +813,7 @@ begin
|
|||||||
MyWorkSheet:= MyWorkBook.AddWorksheet(RowHeightSheet);
|
MyWorkSheet:= MyWorkBook.AddWorksheet(RowHeightSheet);
|
||||||
for Row := Low(SollRowHeights) to High(SollRowHeights) do
|
for Row := Low(SollRowHeights) to High(SollRowHeights) do
|
||||||
MyWorksheet.WriteRowHeight(Row, SollRowHeights[Row]);
|
MyWorksheet.WriteRowHeight(Row, SollRowHeights[Row]);
|
||||||
|
TempFile:=NewTempFile;
|
||||||
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
@ -804,7 +826,8 @@ begin
|
|||||||
MyWorksheet := GetWorksheetByName(MyWorkBook, RowHeightSheet);
|
MyWorksheet := GetWorksheetByName(MyWorkBook, RowHeightSheet);
|
||||||
if MyWorksheet=nil then
|
if MyWorksheet=nil then
|
||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
for Row := Low(SollRowHeights) to High(SollRowHeights) do begin
|
for Row := Low(SollRowHeights) to High(SollRowHeights) do
|
||||||
|
begin
|
||||||
ActualRowHeight := MyWorksheet.GetRowHeight(Row);
|
ActualRowHeight := MyWorksheet.GetRowHeight(Row);
|
||||||
// Take care of rounding errors
|
// Take care of rounding errors
|
||||||
if abs(ActualRowHeight - SollRowHeights[Row]) > 1e-2 then
|
if abs(ActualRowHeight - SollRowHeights[Row]) > 1e-2 then
|
||||||
@ -851,7 +874,6 @@ var
|
|||||||
row: Integer;
|
row: Integer;
|
||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
begin
|
begin
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -859,13 +881,15 @@ begin
|
|||||||
// Write out all test values
|
// Write out all test values
|
||||||
MyWorkbook := TsWorkbook.Create;
|
MyWorkbook := TsWorkbook.Create;
|
||||||
MyWorkSheet:= MyWorkBook.AddWorksheet(TextRotationSheet);
|
MyWorkSheet:= MyWorkBook.AddWorksheet(TextRotationSheet);
|
||||||
for tr := Low(TsTextRotation) to High(TsTextRotation) do begin
|
for tr := Low(TsTextRotation) to High(TsTextRotation) do
|
||||||
|
begin
|
||||||
row := ord(tr);
|
row := ord(tr);
|
||||||
MyWorksheet.WriteTextRotation(row, col, tr);
|
MyWorksheet.WriteTextRotation(row, col, tr);
|
||||||
MyCell := MyWorksheet.GetCell(row, col);
|
MyCell := MyWorksheet.GetCell(row, col);
|
||||||
CheckEquals(ord(tr), ord(MyCell^.TextRotation),
|
CheckEquals(ord(tr), ord(MyCell^.TextRotation),
|
||||||
'Test unsaved textrotation mismatch, cell ' + CellNotation(MyWorksheet, row, col));
|
'Test unsaved textrotation mismatch, cell ' + CellNotation(MyWorksheet, row, col));
|
||||||
end;
|
end;
|
||||||
|
TempFile:=NewTempFile;
|
||||||
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
@ -878,7 +902,8 @@ begin
|
|||||||
MyWorksheet := GetWorksheetByName(MyWorkBook, TextRotationSheet);
|
MyWorksheet := GetWorksheetByName(MyWorkBook, TextRotationSheet);
|
||||||
if MyWorksheet=nil then
|
if MyWorksheet=nil then
|
||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
for row := 0 to MyWorksheet.GetLastRowIndex do begin
|
for row := 0 to MyWorksheet.GetLastRowIndex do
|
||||||
|
begin
|
||||||
MyCell := MyWorksheet.FindCell(row, col);
|
MyCell := MyWorksheet.FindCell(row, col);
|
||||||
if MyCell = nil then
|
if MyCell = nil then
|
||||||
fail('Error in test code. Failed to get cell');
|
fail('Error in test code. Failed to get cell');
|
||||||
@ -919,7 +944,6 @@ var
|
|||||||
MyCell: PCell;
|
MyCell: PCell;
|
||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
begin
|
begin
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -940,6 +964,7 @@ begin
|
|||||||
if MyCell = nil then
|
if MyCell = nil then
|
||||||
fail('Error in test code. Failed to get word-wrapped cell.');
|
fail('Error in test code. Failed to get word-wrapped cell.');
|
||||||
CheckEquals(false, (uffWordWrap in MyCell^.UsedFormattingFields), 'Test unsaved non-wrapped cell mismatch, cell ' + CellNotation(MyWorksheet,0,0));
|
CheckEquals(false, (uffWordWrap in MyCell^.UsedFormattingFields), 'Test unsaved non-wrapped cell mismatch, cell ' + CellNotation(MyWorksheet,0,0));
|
||||||
|
TempFile:=NewTempFile;
|
||||||
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
|
@ -106,7 +106,8 @@ begin
|
|||||||
MyWorksheet := GetWorksheetByName(MyWorkBook, SHEET);
|
MyWorksheet := GetWorksheetByName(MyWorkBook, SHEET);
|
||||||
if MyWorksheet=nil then
|
if MyWorksheet=nil then
|
||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
for Row := 0 to MyWorksheet.GetLastRowIndex do begin
|
for Row := 0 to MyWorksheet.GetLastRowIndex do
|
||||||
|
begin
|
||||||
cell := MyWorksheet.FindCell(Row, 1);
|
cell := MyWorksheet.FindCell(Row, 1);
|
||||||
if (cell <> nil) and (Length(cell^.RPNFormulaValue) > 0) then begin
|
if (cell <> nil) and (Length(cell^.RPNFormulaValue) > 0) then begin
|
||||||
actual := MyWorksheet.ReadRPNFormulaAsString(cell);
|
actual := MyWorksheet.ReadRPNFormulaAsString(cell);
|
||||||
@ -155,8 +156,6 @@ var
|
|||||||
t: TTime;
|
t: TTime;
|
||||||
hr,min,sec,msec: Word;
|
hr,min,sec,msec: Word;
|
||||||
begin
|
begin
|
||||||
TempFile := GetTempFileName;
|
|
||||||
|
|
||||||
// Create test workbook
|
// Create test workbook
|
||||||
MyWorkbook := TsWorkbook.Create;
|
MyWorkbook := TsWorkbook.Create;
|
||||||
MyWorkSheet:= MyWorkBook.AddWorksheet(SHEET);
|
MyWorkSheet:= MyWorkBook.AddWorksheet(SHEET);
|
||||||
@ -170,7 +169,7 @@ begin
|
|||||||
formula in column B. }
|
formula in column B. }
|
||||||
Row := 0;
|
Row := 0;
|
||||||
{$I testcases_calcrpnformula.inc}
|
{$I testcases_calcrpnformula.inc}
|
||||||
|
TempFile:=GetTempFileName;
|
||||||
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
@ -184,7 +183,8 @@ begin
|
|||||||
if MyWorksheet=nil then
|
if MyWorksheet=nil then
|
||||||
fail('Error in test code. Failed to get named worksheet');
|
fail('Error in test code. Failed to get named worksheet');
|
||||||
|
|
||||||
for Row := 0 to MyWorksheet.GetLastRowIndex do begin
|
for Row := 0 to MyWorksheet.GetLastRowIndex do
|
||||||
|
begin
|
||||||
formula := MyWorksheet.ReadAsUTF8Text(Row, 0);
|
formula := MyWorksheet.ReadAsUTF8Text(Row, 0);
|
||||||
cell := MyWorksheet.FindCell(Row, 1);
|
cell := MyWorksheet.FindCell(Row, 1);
|
||||||
if (cell = nil) then
|
if (cell = nil) then
|
||||||
|
@ -30,12 +30,6 @@ type
|
|||||||
private
|
private
|
||||||
procedure NeedVirtualCellData(Sender: TObject; ARow, ACol: Cardinal;
|
procedure NeedVirtualCellData(Sender: TObject; ARow, ACol: Cardinal;
|
||||||
var AValue:Variant; var AStyleCell: PCell);
|
var AValue:Variant; var AStyleCell: PCell);
|
||||||
// Gets new empty temp file and returns the file name
|
|
||||||
// Removes any existing file by that name
|
|
||||||
// Should be called just before writing to the file as
|
|
||||||
// GetTempFileName is used which does not guarantee
|
|
||||||
// file uniqueness
|
|
||||||
function NewTempFile: String;
|
|
||||||
protected
|
protected
|
||||||
// Set up expected values:
|
// Set up expected values:
|
||||||
procedure SetUp; override;
|
procedure SetUp; override;
|
||||||
@ -79,19 +73,6 @@ uses
|
|||||||
const
|
const
|
||||||
InternalSheet = 'Internal'; //worksheet name
|
InternalSheet = 'Internal'; //worksheet name
|
||||||
|
|
||||||
function TSpreadInternalTests.NewTempFile: String;
|
|
||||||
var
|
|
||||||
tempFile: String;
|
|
||||||
begin
|
|
||||||
TempFile := GetTempFileName;
|
|
||||||
if FileExists(TempFile) then
|
|
||||||
begin
|
|
||||||
DeleteFile(TempFile);
|
|
||||||
sleep(40); //e.g. on Windows, give file system chance to perform changes
|
|
||||||
end;
|
|
||||||
Result:=tempFile;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSpreadInternalTests.GetSheetByIndex;
|
procedure TSpreadInternalTests.GetSheetByIndex;
|
||||||
var
|
var
|
||||||
MyWorksheet: TsWorksheet;
|
MyWorksheet: TsWorksheet;
|
||||||
@ -347,12 +328,14 @@ begin
|
|||||||
col := 0;
|
col := 0;
|
||||||
CheckEquals(Length(SollNumbers) + 4, worksheet.GetLastRowIndex+1,
|
CheckEquals(Length(SollNumbers) + 4, worksheet.GetLastRowIndex+1,
|
||||||
'Row count mismatch');
|
'Row count mismatch');
|
||||||
for row := 0 to Length(SollNumbers)-1 do begin
|
for row := 0 to Length(SollNumbers)-1 do
|
||||||
|
begin
|
||||||
value := worksheet.ReadAsNumber(row, col);
|
value := worksheet.ReadAsNumber(row, col);
|
||||||
CheckEquals(SollNumbers[row], value,
|
CheckEquals(SollNumbers[row], value,
|
||||||
'Test number value mismatch, cell '+CellNotation(workSheet, row, col))
|
'Test number value mismatch, cell '+CellNotation(workSheet, row, col))
|
||||||
end;
|
end;
|
||||||
for row := Length(SollNumbers) to worksheet.GetLastRowIndex do begin
|
for row := Length(SollNumbers) to worksheet.GetLastRowIndex do
|
||||||
|
begin
|
||||||
s := worksheet.ReadAsUTF8Text(row, col);
|
s := worksheet.ReadAsUTF8Text(row, col);
|
||||||
CheckEquals(SollStrings[row - Length(SollNumbers)], s,
|
CheckEquals(SollStrings[row - Length(SollNumbers)], s,
|
||||||
'Test string value mismatch, cell '+CellNotation(workSheet, row, col));
|
'Test string value mismatch, cell '+CellNotation(workSheet, row, col));
|
||||||
|
@ -170,7 +170,6 @@ var
|
|||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
begin
|
begin
|
||||||
//todo: add support for ODF format
|
//todo: add support for ODF format
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -185,6 +184,7 @@ begin
|
|||||||
ActualNumber:=MyWorkSheet.ReadAsNumber(Row,0);
|
ActualNumber:=MyWorkSheet.ReadAsNumber(Row,0);
|
||||||
CheckEquals(SollNumbers[Row],ActualNumber,'Test value mismatch cell '+CellNotation(MyWorkSheet,Row));
|
CheckEquals(SollNumbers[Row],ActualNumber,'Test value mismatch cell '+CellNotation(MyWorkSheet,Row));
|
||||||
end;
|
end;
|
||||||
|
TempFile:=NewTempFile;
|
||||||
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
MyWorkBook.WriteToFile(TempFile, AFormat, true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
|
@ -90,6 +90,7 @@
|
|||||||
<Unit3>
|
<Unit3>
|
||||||
<Filename Value="numberstests.pas"/>
|
<Filename Value="numberstests.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="numberstests"/>
|
||||||
</Unit3>
|
</Unit3>
|
||||||
<Unit4>
|
<Unit4>
|
||||||
<Filename Value="manualtests.pas"/>
|
<Filename Value="manualtests.pas"/>
|
||||||
@ -98,6 +99,7 @@
|
|||||||
<Unit5>
|
<Unit5>
|
||||||
<Filename Value="testsutility.pas"/>
|
<Filename Value="testsutility.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="testsutility"/>
|
||||||
</Unit5>
|
</Unit5>
|
||||||
<Unit6>
|
<Unit6>
|
||||||
<Filename Value="internaltests.pas"/>
|
<Filename Value="internaltests.pas"/>
|
||||||
@ -107,6 +109,7 @@
|
|||||||
<Unit7>
|
<Unit7>
|
||||||
<Filename Value="formattests.pas"/>
|
<Filename Value="formattests.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="formattests"/>
|
||||||
</Unit7>
|
</Unit7>
|
||||||
<Unit8>
|
<Unit8>
|
||||||
<Filename Value="colortests.pas"/>
|
<Filename Value="colortests.pas"/>
|
||||||
@ -115,6 +118,7 @@
|
|||||||
<Unit9>
|
<Unit9>
|
||||||
<Filename Value="fonttests.pas"/>
|
<Filename Value="fonttests.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="fonttests"/>
|
||||||
</Unit9>
|
</Unit9>
|
||||||
<Unit10>
|
<Unit10>
|
||||||
<Filename Value="optiontests.pas"/>
|
<Filename Value="optiontests.pas"/>
|
||||||
|
@ -149,7 +149,6 @@ var
|
|||||||
TempFile: string; //write xls/xml to this file and read back from it
|
TempFile: string; //write xls/xml to this file and read back from it
|
||||||
begin
|
begin
|
||||||
//todo: add support for ODF/LibreOffice format
|
//todo: add support for ODF/LibreOffice format
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -164,6 +163,7 @@ begin
|
|||||||
ActualString:=MyWorkSheet.ReadAsUTF8Text(Row,0);
|
ActualString:=MyWorkSheet.ReadAsUTF8Text(Row,0);
|
||||||
CheckEquals(SollStrings[Row],ActualString,'Test value mismatch cell '+CellNotation(MyWorkSheet,Row));
|
CheckEquals(SollStrings[Row],ActualString,'Test value mismatch cell '+CellNotation(MyWorkSheet,Row));
|
||||||
end;
|
end;
|
||||||
|
TempFile:=NewTempFile;
|
||||||
MyWorkBook.WriteToFile(TempFile,sfExcel8,true);
|
MyWorkBook.WriteToFile(TempFile,sfExcel8,true);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
|
||||||
@ -204,7 +204,6 @@ begin
|
|||||||
LocalNormStrings[2]:=StringOfChar('z',MaxBytesBiff8+1); //problems should occur here
|
LocalNormStrings[2]:=StringOfChar('z',MaxBytesBiff8+1); //problems should occur here
|
||||||
LocalNormStrings[3]:='this text should be readable'; //whatever happens, this text should be ok
|
LocalNormStrings[3]:='this text should be readable'; //whatever happens, this text should be ok
|
||||||
|
|
||||||
TempFile:=GetTempFileName;
|
|
||||||
{// Not needed: use workbook.writetofile with overwrite=true
|
{// Not needed: use workbook.writetofile with overwrite=true
|
||||||
if fileexists(TempFile) then
|
if fileexists(TempFile) then
|
||||||
DeleteFile(TempFile);
|
DeleteFile(TempFile);
|
||||||
@ -245,6 +244,7 @@ begin
|
|||||||
CheckTrue(TestResult,'Exception: '+ExceptionMessage);
|
CheckTrue(TestResult,'Exception: '+ExceptionMessage);
|
||||||
end;
|
end;
|
||||||
TestResult:=true;
|
TestResult:=true;
|
||||||
|
TempFile:=NewTempFile;
|
||||||
try
|
try
|
||||||
MyWorkBook.WriteToFile(TempFile,sfExcel8,true);
|
MyWorkBook.WriteToFile(TempFile,sfExcel8,true);
|
||||||
except
|
except
|
||||||
|
@ -37,8 +37,25 @@ function RowNotation(Worksheet: TsWorksheet; Row: Integer): String;
|
|||||||
// older fpspreadsheet versions that don't have that function
|
// older fpspreadsheet versions that don't have that function
|
||||||
function GetWorksheetByName(AWorkBook: TsWorkBook; AName: String): TsWorksheet;
|
function GetWorksheetByName(AWorkBook: TsWorkBook; AName: String): TsWorksheet;
|
||||||
|
|
||||||
|
// Gets new empty temp file and returns the file name
|
||||||
|
// Removes any existing file by that name
|
||||||
|
// Should be called just before writing to the file as
|
||||||
|
// GetTempFileName is used which does not guarantee
|
||||||
|
// file uniqueness
|
||||||
|
function NewTempFile: String;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
function NewTempFile: String;
|
||||||
|
begin
|
||||||
|
Result := GetTempFileName;
|
||||||
|
if FileExists(Result) then
|
||||||
|
begin
|
||||||
|
DeleteFile(Result);
|
||||||
|
sleep(40); //e.g. on Windows, give file system chance to perform changes
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function GetWorksheetByName(AWorkBook: TsWorkBook; AName: String): TsWorksheet;
|
function GetWorksheetByName(AWorkBook: TsWorkBook; AName: String): TsWorksheet;
|
||||||
var
|
var
|
||||||
i:integer;
|
i:integer;
|
||||||
|
Reference in New Issue
Block a user