DEV Community

IronSoftware
IronSoftware

Posted on • Originally published at ironsoftware.com

3 2

Repeat Excel Rows & Columns

When Excel spreadsheets span several pages, the data is easier to read when we print the column titles at the top of every page. These are called "Repeating Rows" in Excel.

"Repeating Rows" and "Repeating Columns" are header rows and columns which repeat on every printed page of an Excel WorkSheet

These are also known as also known as "Duplicate Rows and Columns" and "Header Rows and Columns"

C#:

using IronXL;

WorkBook workbook = WorkBook.Load("test.xlsx");
WorkSheet worksheet = workbook.DefaultWorkSheet;

// SetRepeatingRows is how we can set repeating rows for the print title of the worksheet.  
// The Int parameters are the start and end zero-based row numbers.
// To remove  repeating rows you can use worksheet.RemoveRepeatingRows();  
worksheet.SetRepeatingRows(1, 2);


// SetRepeatingColumns is how we can set repeating columns.
// The Int parameters are the start and end zero-based colum numbers (0 is "A");
// To remove repeating columns you can use worksheet.RemoveRepeatingColumns();
worksheet.SetRepeatingColumns(2,3);


workbook.SaveAs("RepeatingRows.xlsx");
Enter fullscreen mode Exit fullscreen mode

VB:

Imports IronXL

Private workbook As WorkBook = WorkBook.Load("test.xlsx")
Private worksheet As WorkSheet = workbook.DefaultWorkSheet

' SetRepeatingRows is how we can set repeating rows for the print title of the worksheet.  
' The Int parameters are the start and end zero-based row numbers.
' To remove  repeating rows you can use worksheet.RemoveRepeatingRows();  
worksheet.SetRepeatingRows(1, 2)


' SetRepeatingColumns is how we can set repeating columns.
' The Int parameters are the start and end zero-based colum numbers (0 is "A");
' To remove repeating columns you can use worksheet.RemoveRepeatingColumns();
worksheet.SetRepeatingColumns(2,3)


workbook.SaveAs("RepeatingRows.xlsx")
Enter fullscreen mode Exit fullscreen mode

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay