hi,
if we have two sheet (or more) with two table (or more) and we create a slider on each table the file is corrupted.
Code:
var license = new License();
license.SetLicense(“Aspose.Total.lic”);
var file = Path.Combine(TestContext.CurrentContext.TestDirectory, “Ressources”, $"{nameof(BugSlicer)}.xlsx");
if (File.Exists(file))
{
File.Delete(file);
}
using(var workbook = new Workbook())
{
workbook.FileFormat = FileFormatType.Xlsx;
workbook.Worksheets.Clear();
PrepareSheet(workbook, "Data 1");
PrepareSheet(workbook, "Data 2");
workbook.Save(file);
}
Assert.Pass("Validation done by manual file inspection");
with
private static void PrepareSheet(Workbook workbook,string sheetName, bool twoSlider = false)
{
var iIndex = workbook.Worksheets.Add(SheetType.Worksheet);
var sheet = workbook.Worksheets[iIndex];
sheet.Name = sheetName;
workbook.Worksheets.ActiveSheetIndex = sheet.Index;
sheet.ActiveCell = "A1";
sheet.Cells["A1"].PutValue("Col1");
sheet.Cells["B1"].PutValue("Col2");
sheet.Cells["C1"].PutValue("Col3");
sheet.Cells["D1"].PutValue("Col4");
sheet.Cells["E1"].PutValue("Col5");
sheet.Cells["F1"].PutValue("Col6");
for (var i = 2; i < 102; i++)
{
sheet.Cells["A" + i].PutValue(i);
sheet.Cells["B" + i].PutValue(DateTime.Today.AddDays(-i));
sheet.Cells["C" + i].PutValue("Test" + (i % 4));
sheet.Cells["D" + i].PutValue(DateTime.Today.AddDays(i % 8));
sheet.Cells["E" + i].PutValue("Another Test" + (i % 5));
sheet.Cells["F" + i].PutValue(i * 3.14);
}
var dateStyle = workbook.CreateStyle();
dateStyle.Custom = "dd-MM-yyyy";
var flag = new StyleFlag()
{
All = true
};
sheet.Cells.ApplyColumnStyle(1, dateStyle, flag);
sheet.Cells.ApplyColumnStyle(3, dateStyle, flag);
sheet.AutoFitColumns();
// Create Table
var selectedTable = sheet.ListObjects[sheet.ListObjects.Add(0, 0, sheet.Cells.MaxDataRow, sheet.Cells.MaxDataColumn, true)];
var listColumn = selectedTable.ListColumns[2];
sheet.Slicers.Add(selectedTable, listColumn, 5, 7);
if (twoSlider)
{
sheet.Slicers.Add(selectedTable, selectedTable.ListColumns[3], 5, 10);
}
}