Dear Support,
I am using a example provide by appose to created an table in spreadsheet, but I need to disable the filter in each header of columns. Is there a code to do that? This is the code to create the table:
Workbook workbook = new Workbook(dataDir + "book1.xls");
// Get the List objects collection in the first worksheet.
Aspose.Cells.Tables.ListObjectCollection listObjects = workbook.Worksheets[0].ListObjects;
// Add a List based on the data source range with headers on.
listObjects.Add(1, 1, 7, 5, true);
// Show the total row for the List.
listObjects[0].ShowTotals = true;
// Calculate the total of the last (5th ) list column.
listObjects[0].ListColumns[4].TotalsCalculation = Aspose.Cells.Tables.TotalsCalculation.Sum;
// Save the excel file.
workbook.Save(dataDir + "output.xls");
@Mission
Please set the listObjects[0].AutoFilter.Range property to null and it will fix your issue. Here is the rectified sample code, please read its comments for more help.
C#
Workbook workbook = new Workbook(dataDir + "book1.xls");
// Get the List objects collection in the first worksheet.
Aspose.Cells.Tables.ListObjectCollection listObjects = workbook.Worksheets[0].ListObjects;
// Add a List based on the data source range with headers on.
listObjects.Add(1, 1, 7, 5, true);
// Show the total row for the List.
listObjects[0].ShowTotals = true;
// Calculate the total of the last (5th ) list column.
listObjects[0].ListColumns[4].TotalsCalculation = Aspose.Cells.Tables.TotalsCalculation.Sum;
//Add this line and it will fix your issue
listObjects[0].AutoFilter.Range = null;//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// Save the excel file.
workbook.Save(dataDir + "output.xls");
Thank you very much! It worked.
Is there a way I can add some padding of column content or specify each column’s width? Current I had it auto fit using: sheet.AutoFitColumns();
But I’d like to add some padding to the content.
Thanks again!
Gracie
@Mission
Please use AutoFitColumn() method instead of AutoFitColumns() and set the width of individual columns separately with your desired width and it should solve your issue.
Thank you!
What is the code to set up width of individual columns ?
@Mission
Thanks for using Aspose APIs.
Please see the following sample code and its comments for a reference.
C#
//Set the width of the 3rd column - index 2 means 3rd column
ws.Cells.SetColumnWidth(2, 40);
//Set the height of the 5th row - index 4 means 5th row
ws.Cells.SetRowHeight(4, 60);