Page 1 of 1

Only last sheet is converted out of multiple excel sheets

Posted: Fri Dec 06, 2013 4:29 am
by ahsan
Hi,
I am trying to convert an excel document having multiple sheets but only last sheet is being converted.
I am using following code.

Code: Select all

                  IBatchProcessingOptions batchProcessing = p2fServer.DefaultBatchProcessingOptions;
               
                  batchProcessing.ExcelOptions.SheetRange = "1-";
                  batchProcessing.ApplyChanges();
                  p2fServer.ConvertFile(inputPath, outputPath, settingProfile, batchProcessing, null);
I am unable to convert all the sheets.

Re: Only last sheet is converted out of multiple excel sheet

Posted: Fri Dec 06, 2013 4:50 am
by staff
Make sure that special processing method is turned on. You may do it by setting the UseAutomation property of BatchProcessingOptions object like this:

Code: Select all

batchProcessing.UseAutomation=batchProcessing.UseAutomation | 1;

Re: Only last sheet is converted out of multiple excel sheet

Posted: Fri Dec 06, 2013 9:36 am
by ahsan
I included the written line of code and another error arisen.

System.Runtime.InteropServices.COMException: Microsoft Excel cannot access the file 'C:\inetpub\wwwroot\AnasageServerController\uploadedfiles\1386349277\1386349277_sample.xlsx'. There are several possible reasons:

• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook
at Print2Flash3.IServer.ConvertFile(String SourceFileName, String OutputFileName, Object Profile, Object BatchProcessingOptions, Object PrintingPreferences)

Re: Only last sheet is converted out of multiple excel sheet

Posted: Fri Dec 06, 2013 9:42 am
by ahsan
Let me explain what I am doing.

I am doing this conversion on a server(WCF application) having a running print2flash service. I made a request of conversion from my client running on another machine.

Word/Powerpoint documents are being converted fine but issue is with excel in case of multiple sheets incase of adding your line of code.

Re: Only last sheet is converted out of multiple excel sheet

Posted: Fri Dec 06, 2013 9:53 am
by staff
In order to convert multiple sheets you have to use special processing method for MS Excel so this line of code is absolutely necessary. From the error message it seems that MS Excel fails to open the Excel document. You need to find out why MS Excel can't do it. Check if you can open that document manually.