This project has moved. For the latest updates, please go here.

Transpose Ranges

We start with the basic table:

BasicTable.jpg

            var workbook = new XLWorkbook("BasicTable.xlsx");
            var ws = workbook.Worksheet(1);

            var rngTable = ws.Range("B2:F6");

            rngTable.Transpose(XLTransposeOptions.MoveCells);

            ws.Columns().AdjustToContents();

            workbook.SaveAs("TransposeRanges.xlsx");

And we end up with the following table:
Note: Notice how the Transpose function correctly preserves the formats.

TransposeRanges.jpg

Last edited Jan 23, 2011 at 11:29 PM by MDeLeon, version 7