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

Free Support Forum - aspose.com

With the version 5.1.3.4- problem with top fixed rows when applying .FirstRowVisible

Helllo,

I'm forcing the activesheetindex, firstvisiblecolumn and firstvisiblerow in a workbook

My worksheet has 3 fixed rows at the top

With the version 5.1.1.0 the display works fine but the freezing was cancelled

With the version 5.1.3.4 the display is wrong

See attached screens

Regards

Dimitri

Hi,

Please post your sample code with template (input) file and output file here, we will check it soon. I have a doubt there might be some issue/minor error with your code, not sure though.

Thank you.

Hello Amjad,

Thanks for your fast reply. My project is not simple enough to extract the sample from. Have you tried at your side ?

Last time i've submitted a bug, i spend 3 hours to extract the exact steps. It'll worth it if you are unable to reproduce the bug at your side

Thanks

Dimitri

This is a part of the code that i was able to easily extract :

public void Save(System.IO.Stream stream, string selectedSheetName, int selectedRow, int selectedColumn)

{

Worksheet activeSheet = _workbook.Worksheets[selectedSheetName];

_workbook.Worksheets.ActiveSheetIndex = activeSheet.Index;

activeSheet.ActiveCell = activeSheet.Cells[selectedRow, selectedColumn].Name;

activeSheet.FirstVisibleColumn = (selectedColumn > 15 ? selectedColumn-3 : 0);

activeSheet.FirstVisibleRow = (selectedRow > 15 ? selectedRow - 5 : selectedRow);

Save(stream);

}

Hi,

You gave us the generic code which looks fine to me.

Please post your template file, output file (after activation of cell in row/column in panes) by Aspose.Cells and your desired file (you can manually activate your desired cell(s) in rows/columns in panes).

We will check your issue soon.

Thank you.


The test file "aspose_test_sliding.xls" is attached. "aspose_test_sliding_selected.xls" is the result of the code execution. We expect the main area of the worksheet is scrolled, but in "aspose_test_sliding_selected.xls" the fixed rows in the top are scrolled instead.

Here's the sample code to reproduce the bug:


using System;

using Aspose.Cells;

namespace Test
{
public class Program
{
public static void Save(Workbook _workbook, string selectedSheetName, int selectedRow, int selectedColumn)
{
Worksheet activeSheet = _workbook.Worksheets[selectedSheetName];
_workbook.Worksheets.ActiveSheetIndex = activeSheet.Index;
activeSheet.ActiveCell = activeSheet.Cells[selectedRow, selectedColumn].Name;
activeSheet.FirstVisibleColumn = (selectedColumn > 15 ? selectedColumn - 3 : 0);
activeSheet.FirstVisibleRow = (selectedRow > 15 ? selectedRow - 5 : selectedRow);
_workbook.Save("aspose_test_sliding_selected.xls");
}

public static void Main(string[] args)
{
Workbook workbook = new Workbook("aspose_test_sliding.xls");
Save(workbook, "et trois", 300, 5);

}
}
}

Hi,

I think you need to modify/update your code a bit, also you need to use PaneCollection API for your need as you have some frozen rows/columns in your desired sheet.

Here is my sample code, I have tested it with your template file, it works fine for your requirement now, so try it:

Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense(@“E:\Licenses\new4\Aspose.Cells.lic”);

Workbook _workbook = new Workbook(“e:\test\topfixed\aspose_test_sliding.xls”);
int selectedColumn = 5;
int selectedRow = 300;
Worksheet activeSheet = _workbook.Worksheets[“et trois”];
_workbook.Worksheets.ActiveSheetIndex = activeSheet.Index;
activeSheet.ActiveCell = activeSheet.Cells[selectedRow, selectedColumn].Name;
activeSheet.FirstVisibleColumn = 0;
activeSheet.FirstVisibleRow = 0;
PaneCollection panes = activeSheet.GetPanes();
panes.FirstVisibleColumnOfRightPane = (selectedColumn > 15 ? selectedColumn - 3 : 0);
panes.FirstVisibleRowOfBottomPane = (selectedRow > 15 ? selectedRow - 5 : selectedRow);

_workbook.Save(“e:\test\topfixed\outaspose_test_sliding_selected.xls”);


Thank you.

thanks, it works as you said

the only thing is that if i don't have panes, the collection is null. So i have to check in the code if there are panes and set the visible row and column in two ways like this

PaneCollection panes = activeSheet.GetPanes();

if (panes == null)

{

activeSheet.FirstVisibleColumn = (selectedColumn > 15 ? selectedColumn - 5 : 0);

activeSheet.FirstVisibleRow = (selectedRow > 15 ? selectedRow - 10 : 0);

}

else

{

activeSheet.FirstVisibleColumn = 0;

activeSheet.FirstVisibleRow = 0;

if(selectedColumn > 15)

panes.FirstVisibleColumnOfRightPane = selectedColumn - 5;

if(selectedRow > 15)

panes.FirstVisibleRowOfBottomPane = selectedRow - 10;

}

thanks for help