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

Free Support Forum - aspose.com

Freez Top Three Rows With Different Columns in Excel

Hi Team,

I have attached my requirement/expected result.

Please guide me how acheive that output.

I need to freez top header three rows. all my top three header have different, different columns.

How I can acheive this freez panel for all three rows.

Please assesst me.

Thanks,

Naveen

Hi Naveen,


Please check the below provided code snippet & attached resultant spreadsheet. We hope this fullfils your requirements.

Java

//Load spreadsheet in an instance of Workbook
Workbook workbook = new Workbook(“D:/temp/example_of+the+required+template.xlsx”);

//Get worksheet on which freeze pane has to be applied
//In this case we are getting the 2nd worksheet from the collection
Worksheet sheet1 = workbook.getWorksheets().get(1);

//FreezePane on first three rows whereas maximum coloumn is calculated by the data
sheet1.freezePanes(3, 0, 3, sheet1.getCells().getMaxColumn()+1);

//Save results
workbook.save(myDir + “output.xlsx”, SaveFormat.XLSX);

Hi,

When I tried with above code I got below exception:

Invalid parameters of freeze panes

java.lang.IllegalArgumentException: Invalid parameters of freeze panes

at com.aspose.cells.F.a(Unknown Source)

at com.aspose.cells.Worksheet.freezePanes(Unknown Source)

Api Version: aspose-cells.2.5.3.1

Sorry to missing below requirement:

While Loading the formate from DB. I deleting 3 to 6 rows using below code.

Cells cells = sheet.getCells();

cells.deleteRows(3, 6, true); // So it will delete 4 to 6 rows

those columns contain some unwanted data, So I have to delete while loading. After deleting we are filling the data to templat.

Hi Naveen,


We have evaluated the presented scenario while using the latest version of Aspose.Cells for Java (Latest Version). As you are using a very old version of the API, there could be bug(s) in that release that is why we would suggest you to use the latest build (link shared above). Moreover, we have also tried by deleting the specified rows before & after freezing the pane.

Please give the latest version a try on your end to see the results.

Hi,

I have done the top three rows freeze using below code:

sheet.freezePanes(3, 0, 3, 0);

Issue: After end of data columns in header, printing dark line.

I don't have any idea, why its printing please help me on this.

For more details please refer attached document.

While searching I got this blog. Please check this: https://forum.aspose.com/t/119514

Hi,


Yes, your file “Test.xlsx” shows the correct behavior.

This code will freeze the complete 4th row. If you could perform the same operation in MS Excel: “e.g In MS Excel 2007/2010 open your file’s first sheet, Click on Cell A3, Click View(Menu), click Freeze Panes button/icon and then click “FreezePanes” option”, you will get the same result, the similar black/ dark (frozen) line would be appeared in the 4th row (up to the end of column in the worksheet). So, Aspose.Cells works the same way as MS Excel does. If you still have any confusion regarding FreezePanes/ unfreeze panes, please perform your operation (freezing panes operation) in a sample file in Ms Excel and provide us here, we will tell you how to do it with Aspose.Cells APIs.

Thank you.