We're sorry AsposeCloud doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.cloud

How to remove a sheet in Excel to PDF Conversion in C#


We are using Aspose.Cells.Cloud.SDK to convert excel files to PDF. There is a ‘Help’ sheet in all these excel documents that just contains instructions, which I don’t want to see in the final PDF document. Is there a way I can remove this sheet from converting to PDF?

Any help is greatly appreciated. Thank you in advance.



Please delete the ‘Help’ sheet from the Excel file and convert the Excel file to a PDF file.

Refer to the following code:

string name = “CustomTest_7212.xlsx”;
string needRemovedSheet = “Help”;
CellsApi cellsApi = new CellsApi("your client id ", “your client secret”);
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.SaveFormat = “pdf”;
pdfSaveOptions.OnePagePerSheet = true;
Stream stream = Tools.GetFileStream(“Book1.xlsx”);
stream.Seek(0, SeekOrigin.Begin);
cellsApi.UploadFile(name, stream);
cellsApi.CellsWorksheetsDeleteWorksheet(name, needRemovedSheet);
cellsApi.CellsSaveAsPostDocumentSaveAs(name, pdfSaveOptions, “CustomTest_7212.pdf”);

1 Like

Hi @wangtao
I was able to implement this successfully but the requirements to delete worksheets increased with time. Is there a way where I can delete multiple worksheets in a single call ? I am looking to simplify the below statements. Also, all this code is in a for loop which is sometimes causing the ‘CellsWorksheetsDeleteWorksheet’ to fail. Please let me know if there is an efficient way of doing it.

                    string needRemovedSheet = "xyz";
                    string needRemovedSheet1 = "abc";
                    string needRemovedSheet2 = "def";
                    string needRemovedSheet3 = "ghi";
                    string needRemovedSheet4 = "jkl";
                    string needRemovedSheet5 = "mno";

apiInstance.CellsWorksheetsDeleteWorksheet(name, needRemovedSheet, folder, storage);
apiInstance.CellsWorksheetsDeleteWorksheet(name, needRemovedSheet1, folder, storage);
apiInstance.CellsWorksheetsDeleteWorksheet(name, needRemovedSheet2, folder, storage);
apiInstance.CellsWorksheetsDeleteWorksheet(name, needRemovedSheet3, folder, storage);
apiInstance.CellsWorksheetsDeleteWorksheet(name, needRemovedSheet4, folder, storage);
apiInstance.CellsWorksheetsDeleteWorksheet(name, needRemovedSheet5, folder, storage);

Appreciate all your time and help. Thank you in advance.


Now, Aspose.Cells Cloud API does not support multiple worksheets in a single call. But we will add this feature for you in the next version.

Hi @wangtao Thank you for your response.


We had released Aspose.Cells Cloud SDK 21.10 for DotNet. It supports deleting multiple worksheets in a single call.
Please refer to the following online development document about the feature.


CellsApi instance = new CellsApi(clientId, clientSecret);
MatchConditionRequest matchConditionRequest = new MatchConditionRequest();
matchConditionRequest.FullMatchConditions = new List() { “Sheet1”, “Sheet2”, “Sheet3” }; ;
var name = “Book1.xlsx”;
string folder = “DotNetTest”;
UpdateDataFile(instance, folder, “Book1.xlsx”);
var response = instance.CellsWorksheetsDeleteWorksheets(name, matchConditionRequest, folder);