Microsoft Office Excel did not find anything to print

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
pihionx
Posts: 3
Joined: Wed Apr 30, 2014 6:11 am

Microsoft Office Excel did not find anything to print

Post 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.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Microsoft Office Excel did not find anything to print

Post by larsa »

Hello

I can't reproduce this. Please provide more info about the file you try to print.
Lars Arvidsson, Axolot Data
pihionx
Posts: 3
Joined: Wed Apr 30, 2014 6:11 am

Re: Microsoft Office Excel did not find anything to print

Post 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.
pihionx
Posts: 3
Joined: Wed Apr 30, 2014 6:11 am

Re: Microsoft Office Excel did not find anything to print

Post by pihionx »

Hi Larsa,

Any update?

Thanks.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Microsoft Office Excel did not find anything to print

Post by larsa »

Hello

As you don't add any cell values in your sample, there is nothing to print.
Lars Arvidsson, Axolot Data
Post Reply