Only last sheet is converted out of multiple excel sheets

Using Batch Processing and Enhanced Batch Processing
Post Reply
ahsan
Posts: 34
Joined: Thu Oct 31, 2013 8:41 am

Only last sheet is converted out of multiple excel sheets

Post by ahsan » Fri Dec 06, 2013 4:29 am

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.

staff
Posts: 281
Joined: Sat Dec 15, 2007 4:48 pm

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

Post by staff » Fri Dec 06, 2013 4:50 am

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;

ahsan
Posts: 34
Joined: Thu Oct 31, 2013 8:41 am

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

Post by ahsan » Fri Dec 06, 2013 9:36 am

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)

ahsan
Posts: 34
Joined: Thu Oct 31, 2013 8:41 am

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

Post by ahsan » Fri Dec 06, 2013 9:42 am

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.

staff
Posts: 281
Joined: Sat Dec 15, 2007 4:48 pm

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

Post by staff » Fri Dec 06, 2013 9:53 am

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.

Post Reply