Esempio n. 1
0
        public void TestColumn()
        {
            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 = (3);
            col4.max = (6);

            // Remember - POI column 0 == OOXML column 1
            ColumnHelper helper = new ColumnHelper(worksheet);

            Assert.IsNotNull(helper.GetColumn(0, false));
            Assert.IsNotNull(helper.GetColumn(1, false));
            Assert.AreEqual(88.0, helper.GetColumn(0, false).width, 0.0);
            Assert.AreEqual(0.0, helper.GetColumn(1, false).width, 0.0);
            Assert.IsTrue(helper.GetColumn(0, false).hidden);
            Assert.IsFalse(helper.GetColumn(1, false).hidden);
            Assert.IsNull(helper.GetColumn(99, false));
            Assert.IsNotNull(helper.GetColumn(5, false));
        }
Esempio n. 2
0
        public void CleanColumns()
        {
            this.newCols = new CT_Cols();

            CT_Cols        aggregateCols = new CT_Cols();
            List <CT_Cols> colsList      = worksheet.GetColsList();

            if (colsList == null)
            {
                return;
            }

            foreach (CT_Cols cols in colsList)
            {
                foreach (CT_Col col in cols.GetColList())
                {
                    CloneCol(aggregateCols, col);
                }
            }

            SortColumns(aggregateCols);

            CT_Col[] colArray = aggregateCols.GetColList().ToArray();
            SweepCleanColumns(newCols, colArray, null);

            int i = colsList.Count;

            for (int y = i - 1; y >= 0; y--)
            {
                worksheet.RemoveCols(y);
            }
            worksheet.AddNewCols();
            worksheet.SetColsArray(0, newCols);
        }
Esempio n. 3
0
        //YK: GetXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
        public void CleanColumns()
        {
            this.newCols = new CT_Cols();
            List <CT_Cols> colsArray = worksheet.GetColsArray();

            if (null != colsArray)
            {
                int i = 0;
                for (i = 0; i < colsArray.Count; i++)
                {
                    CT_Cols       cols     = colsArray[i];
                    List <CT_Col> colArray = cols.GetColArray();
                    for (int y = 0; y < colArray.Count; y++)
                    {
                        CT_Col col = colArray[y];
                        newCols = AddCleanColIntoCols(newCols, col);
                    }
                }
                for (int y = i - 1; y >= 0; y--)
                {
                    worksheet.RemoveCols(y);
                }
            }
            worksheet.AddNewCols();
            worksheet.SetColsArray(0, newCols);
        }
Esempio n. 4
0
        public void CleanColumns()
        {
            TreeSet <CT_Col> trackedCols = new TreeSet <CT_Col>(CTColComparator.BY_MIN_MAX);
            CT_Cols          newCols     = new CT_Cols();

            CT_Cols[] colsArray = worksheet.GetColsList().ToArray();
            int       i         = 0;

            for (i = 0; i < colsArray.Length; i++)
            {
                CT_Cols  cols     = colsArray[i];
                CT_Col[] colArray = cols.GetColList().ToArray();
                foreach (CT_Col col in colArray)
                {
                    addCleanColIntoCols(newCols, col, trackedCols);
                }
            }
            for (int y = i - 1; y >= 0; y--)
            {
                worksheet.RemoveCols(y);
            }

            newCols.SetColArray(trackedCols.ToArray(new CT_Col[trackedCols.Count]));
            worksheet.AddNewCols();
            worksheet.SetColsArray(0, newCols);
            //this.newCols = new CT_Cols();

            //CT_Cols aggregateCols = new CT_Cols();
            //List<CT_Cols> colsList = worksheet.GetColsList();
            //if (colsList == null)
            //{
            //    return;
            //}

            //foreach (CT_Cols cols in colsList)
            //{
            //    foreach (CT_Col col in cols.GetColList())
            //    {
            //        CloneCol(aggregateCols, col);
            //    }
            //}

            //SortColumns(aggregateCols);

            //CT_Col[] colArray = aggregateCols.GetColList().ToArray();
            //SweepCleanColumns(newCols, colArray, null);

            //int i = colsList.Count;
            //for (int y = i - 1; y >= 0; y--)
            //{
            //    worksheet.RemoveCols(y);
            //}
            //worksheet.AddNewCols();
            //worksheet.SetColsArray(0, newCols);
        }
Esempio n. 5
0
        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);
        }