Completed
Last Updated: 23 Jun 2020 13:14 by ADMIN
Release 2020.R3
Isha
Created on: 21 Apr 2020 10:10
Category: Spreadsheet
Type: Bug Report
1
Incorrect server-side import of frozen panes when the sheet is scrolled before saving

The Workbook.FromDocument() method freezes the panes based on the coordinates of the TopLeftCellIndex of the pane instead of the XSplit and YSplit properties of the pane. Reproduced with the attached Excel file

var pane = documentWorksheet.ViewState.Pane;
if (pane != null && pane.State == PaneState.Frozen)
{
    sheet.FrozenRows = pane.TopLeftCellIndex.RowIndex;
    sheet.FrozenColumns = pane.TopLeftCellIndex.ColumnIndex;
}

Solution:

var pane = documentWorksheet.ViewState.Pane;
if (pane != null && pane.State == PaneState.Frozen)
{
    sheet.FrozenRows = pane.YSplit;
    sheet.FrozenColumns = pane.XSplit;
}

WORKAROUND: Loading the Excel file with DocumentProcessingLibrary API and change the pane

var fileName = <YourFilePathHere...>;
if (!File.Exists(fileName))
{
    throw new FileNotFoundException(String.Format("File {0} was not found!", fileName));
}

Telerik.Windows.Documents.Spreadsheet.Model.Workbook workbook;
IWorkbookFormatProvider formatProvider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.XlsxFormatProvider();

using (Stream input = new FileStream(fileName, FileMode.Open))
{
    workbook = formatProvider.Import(input);
    foreach (var sheet in workbook.Worksheets)
    {
        if (sheet.ViewState.Pane != null && sheet.ViewState.Pane.State == Telerik.Windows.Documents.Spreadsheet.Model.PaneState.Frozen)
        {

            var originalPane = sheet.ViewState.Pane;
            var pane = new Pane(new CellIndex(originalPane.YSplit, originalPane.XSplit), originalPane.XSplit, originalPane.YSplit, originalPane.ActivePane);
            sheet.ViewState.Pane = pane;
        }
    }
}
var sheets = Telerik.Web.Spreadsheet.Workbook.FromDocument(workbook).Sheets;

 

 

 

Attached Files:
0 comments