コード例 #1
0
        //static string _ColLetter( int col /* 0 origin */) {
        //	// col = [0...25]
        //	if( col >= 0 && col <= 25 )
        //		return ((char)('A' + col)).ToString();
        //	return "";
        //}
        //static string ColLetter( int col /* 1 Origin */) {
        //	if( col < 1 || col > 256 )
        //		throw new ExcelBadUsageException( "Column out of range; must be between 1 and 256" ); // Excel limits
        //	col--; // make 0 origin
        //	// good up to col ZZ
        //	int col2 = (col / 26) - 1;
        //	int col1 = (col % 26);
        //	return _ColLetter( col2 ) + _ColLetter( col1 );
        //}

        #endregion

        #region "  RowValues  "

        private object[] RowValues(int rowNum, int startCol, int numberOfCols)
        {
            if (mSheet == null)
            {
                return(null);
            }

            if (numberOfCols == 1)
            {
                IRow row = mSheet.GetRow(rowNum);

                ICell cell = HSSFCellUtil.GetCell(row, startCol);
                return(new object[] { NPOIUtils.GetCellValue(cell) });
            }
            else
            {
                CellRangeAddress range = new CellRangeAddress(rowNum, rowNum, startCol, startCol + numberOfCols - 1);

                CellWalk cw = new CellWalk(mSheet, range);
                cw.SetTraverseEmptyCells(true);

                CellExtractor ce = new CellExtractor();

                cw.Traverse(ce);

                return(ce.CellValues);
            }
        }
コード例 #2
0
        private object[] RowValues( int rowNum, int startCol, int numberOfCols )
        {
            if( mSheet == null )
                return null;

            if( numberOfCols == 1 ) {
                IRow row = HSSFCellUtil.GetRow( rowNum, (HSSFSheet)mSheet );

                ICell cell = HSSFCellUtil.GetCell( row, startCol );
                return new object[] { NPOIUtils.GetCellValue( cell ) };
            } else {

                CellRangeAddress range = new CellRangeAddress( rowNum, rowNum, startCol, startCol + numberOfCols - 1 );

                CellWalk cw = new CellWalk( mSheet, range );
                cw.SetTraverseEmptyCells( true );
                CellExtractor ce = new CellExtractor();
                cw.Traverse( ce );

                return ce.CellValues;
            }
        }