private SetRepeatingRowsAndColumns ( int sheetIndex, int startColumn, int endColumn, int startRow, int endRow ) : void | ||
sheetIndex | int | |
startColumn | int | |
endColumn | int | |
startRow | int | |
endRow | int | |
Résultat | void |
public void TestRepeatingRowsAndColums() { // First Test that Setting RR&C for same sheet more than once only Creates a // single Print_Titles built-in record XSSFWorkbook wb = new XSSFWorkbook(); wb.CreateSheet("First Sheet"); wb.SetRepeatingRowsAndColumns(0, -1, -1, -1, -1); // Set repeating rows and columns twice for the first sheet for (int i = 0; i < 2; i++) { wb.SetRepeatingRowsAndColumns(0, 0, 0, 0, 3); //sheet.CreateFreezePane(0, 3); } Assert.AreEqual(1, wb.NumberOfNames); IName nr1 = wb.GetNameAt(0); Assert.AreEqual(XSSFName.BUILTIN_PRINT_TITLE, nr1.NameName); Assert.AreEqual("'First Sheet'!$A:$A,'First Sheet'!$1:$4", nr1.RefersToFormula); //remove the columns part wb.SetRepeatingRowsAndColumns(0, -1, -1, 0, 3); Assert.AreEqual("'First Sheet'!$1:$4", nr1.RefersToFormula); //revert wb.SetRepeatingRowsAndColumns(0, 0, 0, 0, 3); //remove the rows part wb.SetRepeatingRowsAndColumns(0, 0, 0, -1, -1); Assert.AreEqual("'First Sheet'!$A:$A", nr1.RefersToFormula); //revert wb.SetRepeatingRowsAndColumns(0, 0, 0, 0, 3); // Save and re-open IWorkbook nwb = XSSFTestDataSamples.WriteOutAndReadBack(wb); Assert.AreEqual(1, nwb.NumberOfNames); nr1 = nwb.GetNameAt(0); Assert.AreEqual(XSSFName.BUILTIN_PRINT_TITLE, nr1.NameName); Assert.AreEqual("'First Sheet'!$A:$A,'First Sheet'!$1:$4", nr1.RefersToFormula); // check that Setting RR&C on a second sheet causes a new Print_Titles built-in // name to be Created nwb.CreateSheet("SecondSheet"); nwb.SetRepeatingRowsAndColumns(1, 1, 2, 0, 0); Assert.AreEqual(2, nwb.NumberOfNames); IName nr2 = nwb.GetNameAt(1); Assert.AreEqual(XSSFName.BUILTIN_PRINT_TITLE, nr2.NameName); Assert.AreEqual("SecondSheet!$B:$C,SecondSheet!$1:$1", nr2.RefersToFormula); nwb.SetRepeatingRowsAndColumns(1, -1, -1, -1, -1); }
public void TestRepeatingRowsAndColums() { // First Test that Setting RR&C for same sheet more than once only Creates a // single Print_Titles built-in record XSSFWorkbook wb = new XSSFWorkbook(); wb.CreateSheet("First Sheet"); wb.SetRepeatingRowsAndColumns(0, -1, -1, -1, -1); // Set repeating rows and columns twice for the first sheet for (int i = 0; i < 2; i++) { wb.SetRepeatingRowsAndColumns(0, 0, 0, 0, 3); //sheet.CreateFreezePane(0, 3); } Assert.AreEqual(1, wb.NumberOfNames); IName nr1 = wb.GetNameAt(0); Assert.AreEqual(XSSFName.BUILTIN_PRINT_TITLE, nr1.NameName); Assert.AreEqual("'First Sheet'!$A:$A,'First Sheet'!$1:$4", nr1.RefersToFormula); //remove the columns part wb.SetRepeatingRowsAndColumns(0, -1, -1, 0, 3); Assert.AreEqual("'First Sheet'!$1:$4", nr1.RefersToFormula); //revert wb.SetRepeatingRowsAndColumns(0, 0, 0, 0, 3); //remove the rows part wb.SetRepeatingRowsAndColumns(0, 0, 0, -1, -1); Assert.AreEqual("'First Sheet'!$A:$A", nr1.RefersToFormula); //revert wb.SetRepeatingRowsAndColumns(0, 0, 0, 0, 3); // Save and re-open IWorkbook nwb = XSSFTestDataSamples.WriteOutAndReadBack(wb); Assert.AreEqual(1, nwb.NumberOfNames); nr1 = nwb.GetNameAt(0); Assert.AreEqual(XSSFName.BUILTIN_PRINT_TITLE, nr1.NameName); Assert.AreEqual("'First Sheet'!$A:$A,'First Sheet'!$1:$4", nr1.RefersToFormula); // check that Setting RR&C on a second sheet causes a new Print_Titles built-in // name to be Created nwb.CreateSheet("SecondSheet"); nwb.SetRepeatingRowsAndColumns(1, 1, 2, 0, 0); Assert.AreEqual(2, nwb.NumberOfNames); IName nr2 = nwb.GetNameAt(1); Assert.AreEqual(XSSFName.BUILTIN_PRINT_TITLE, nr2.NameName); Assert.AreEqual("SecondSheet!$B:$C,SecondSheet!$1:$1", nr2.RefersToFormula); nwb.SetRepeatingRowsAndColumns(1, -1, -1, -1, -1); }
static void Main(string[] args) { IWorkbook wb = new XSSFWorkbook(); ISheet sheet1 = wb.CreateSheet("new sheet"); ISheet sheet2 = wb.CreateSheet("second sheet"); // Set the columns to repeat from column 0 to 2 on the first sheet IRow row1 = sheet1.CreateRow(0); row1.CreateCell(0).SetCellValue(1); row1.CreateCell(1).SetCellValue(2); row1.CreateCell(2).SetCellValue(3); IRow row2 = sheet1.CreateRow(1); row2.CreateCell(1).SetCellValue(4); row2.CreateCell(2).SetCellValue(5); IRow row3 = sheet2.CreateRow(1); row3.CreateCell(0).SetCellValue(2.1); row3.CreateCell(4).SetCellValue(2.2); row3.CreateCell(5).SetCellValue(2.3); IRow row4 = sheet2.CreateRow(2); row4.CreateCell(4).SetCellValue(2.4); row4.CreateCell(5).SetCellValue(2.5); // Set the columns to repeat from column 0 to 2 on the first sheet wb.SetRepeatingRowsAndColumns(0, 0, 2, -1, -1); // Set the the repeating rows and columns on the second sheet. wb.SetRepeatingRowsAndColumns(1, 4, 5, 1, 2); //set the print area for the first sheet wb.SetPrintArea(0, 1, 2, 0, 3); FileStream sw = File.Create("test.xlsx"); wb.Write(sw); sw.Close(); }
public void Test49253() { XSSFWorkbook wb1 = new XSSFWorkbook(); XSSFWorkbook wb2 = new XSSFWorkbook(); // No print Settings before repeating XSSFSheet s1 = wb1.CreateSheet() as XSSFSheet; Assert.AreEqual(false, s1.GetCTWorksheet().IsSetPageSetup()); Assert.AreEqual(true, s1.GetCTWorksheet().IsSetPageMargins()); wb1.SetRepeatingRowsAndColumns(0, 2, 3, 1, 2); Assert.AreEqual(true, s1.GetCTWorksheet().IsSetPageSetup()); Assert.AreEqual(true, s1.GetCTWorksheet().IsSetPageMargins()); XSSFPrintSetup ps1 = s1.PrintSetup as XSSFPrintSetup; Assert.AreEqual(false, ps1.ValidSettings); Assert.AreEqual(false, ps1.Landscape); // Had valid print Settings before repeating XSSFSheet s2 = wb2.CreateSheet() as XSSFSheet; XSSFPrintSetup ps2 = s2.PrintSetup as XSSFPrintSetup; Assert.AreEqual(true, s2.GetCTWorksheet().IsSetPageSetup()); Assert.AreEqual(true, s2.GetCTWorksheet().IsSetPageMargins()); ps2.Landscape=(false); Assert.AreEqual(true, ps2.ValidSettings); Assert.AreEqual(false, ps2.Landscape); wb2.SetRepeatingRowsAndColumns(0, 2, 3, 1, 2); ps2 = s2.PrintSetup as XSSFPrintSetup; Assert.AreEqual(true, s2.GetCTWorksheet().IsSetPageSetup()); Assert.AreEqual(true, s2.GetCTWorksheet().IsSetPageMargins()); Assert.AreEqual(true, ps2.ValidSettings); Assert.AreEqual(false, ps2.Landscape); }