Page 1 of 1
Microsoft Office Excel did not find anything to print
Posted: Fri Jun 13, 2014 9:31 am
by pihionx
Hi,
I encounter error 'Microsoft Office Excel did not find anything to print' while trying to 'print preview' generated file in xls format.
Error will not emerge if the file extension is .xlsx.
Right click the generated worksheet, select move and copy then cancel will enable the print preview but my client won't accept this solution and they also don't want to print in xlsx format.
Please help.
Thanks.
Re: Microsoft Office Excel did not find anything to print
Posted: Tue Jun 17, 2014 1:22 pm
by larsa
Hello
I can't reproduce this. Please provide more info about the file you try to print.
Re: Microsoft Office Excel did not find anything to print
Posted: Tue Jul 22, 2014 2:27 am
by pihionx
Hi Larsa,
I use below procedure to automate the creation worksheet(s).
Code: Select all
procedure XLSRWDefineWorkSheet(const workSheetName: array of string; bDeletedSheet1: Boolean = True);
var
loop, subLoop, nWorkSheetIndex: integer;
isWorkSheetExist: Boolean;
begin
nWorkSheetIndex := XLSRW.Count - 1;
// add worksheet if no of workSheetName more than 0
if (high(workSheetName) >= 0) then
begin
for loop := 0 to high(workSheetName) do
begin
isWorkSheetExist := False;
if Trim(workSheetName[loop]) <> '' then
begin
for subLoop := 0 to nWorkSheetIndex do
if Trim(XLSRW[subLoop].Name) = Trim(workSheetName[loop]) then
isWorkSheetExist := True;
if (not isWorkSheetExist) then
begin
nWorkSheetIndex := nWorkSheetIndex + 1;
XLSRW.Add;
XLSRW[nWorkSheetIndex].Name := Trim(workSheetName[loop]);
end;
end;
end;
end;
if bDeletedSheet1 then
begin
isWorkSheetExist := False;
for subLoop := 0 to nWorkSheetIndex do
if Trim(XLSRW[subLoop].Name) = 'Sheet1' then
isWorkSheetExist := True;
if isWorkSheetExist then
XLSRW.Delete(XLSRW.SheetByName('Sheet1').Index, 1);
end;
end;
Then I call it as below:
Code: Select all
var
XLSRW: TXLSReadWriteII5;
loop: integer;
begin
XLSRW.Version := xvExcel97;
for loop := 201401 to 201412 do
XLSRWDefineWorkSheet([IntToStr(loop)]); // expect to create worksheets '201401' until '201412'
// write to excel and formatting ....
XLSRW.SaveToFile(templatePath);
end;
The problem is because I remove (delete) the default worksheet 'Sheet1' because I expect the generated excel file will only contain the worksheet '201401' until '201412'.
Did i miss anything while deleting 'Sheet1'?
Please help.
Thanks.
Re: Microsoft Office Excel did not find anything to print
Posted: Tue Aug 19, 2014 9:43 am
by pihionx
Hi Larsa,
Any update?
Thanks.
Re: Microsoft Office Excel did not find anything to print
Posted: Tue Aug 19, 2014 1:40 pm
by larsa
Hello
As you don't add any cell values in your sample, there is nothing to print.