public void TestCleanColumns()
        {
            CT_Worksheet worksheet = new CT_Worksheet();

            CT_Cols cols1 = worksheet.AddNewCols();
            CT_Col col1 = cols1.AddNewCol();
            col1.min = (1);
            col1.max = (1);
            col1.width = (88);
            col1.hidden = (true);
            CT_Col col2 = cols1.AddNewCol();
            col2.min = (2);
            col2.max = (3);
            CT_Cols cols2 = worksheet.AddNewCols();
            CT_Col col4 = cols2.AddNewCol();
            col4.min = (13);
            col4.max = (16384);

            // Test cleaning cols
            Assert.AreEqual(2, worksheet.sizeOfColsArray());
            int count = countColumns(worksheet);
            Assert.AreEqual(16375, count);
            // Clean columns and Test a clean worksheet
            ColumnHelper helper = new ColumnHelper(worksheet);
            Assert.AreEqual(1, worksheet.sizeOfColsArray());
            count = countColumns(worksheet);
            Assert.AreEqual(16375, count);
            // Remember - POI column 0 == OOXML column 1
            Assert.AreEqual(88.0, helper.GetColumn(0, false).width, 0.0);
            Assert.IsTrue(helper.GetColumn(0, false).hidden);
            Assert.AreEqual(0.0, helper.GetColumn(1, false).width, 0.0);
            Assert.IsFalse(helper.GetColumn(1, false).hidden);
        }
Exemple #2
0
 private static int countColumns(CT_Worksheet worksheet)
 {
     int count;
     count = 0;
     for (int i = 0; i < worksheet.sizeOfColsArray(); i++)
     {
         for (int y = 0; y < worksheet.GetColsArray(i).sizeOfColArray(); y++)
         {
             for (long k = worksheet.GetColsArray(i).GetColArray(y).min; k <= worksheet
                     .GetColsArray(i).GetColArray(y).max; k++)
             {
                 count++;
             }
         }
     }
     return count;
 }