Example #1
0
        public void setColor(long value)
        {
            try
            {
                if (readOnly)
                {
                    m_errAccess.setErrDes("Can not modify a readonly document");
                    m_errAccess.setErrCod((short)13);
                    return;
                }

                for (int i = 1; i <= cntCells; i++)
                {
                    ExcelFont fontCell = GetFont(i);
                    int       val      = (int)value;
                    fontCell.Color.SetColor(GXExcelHelper.ResolveColor(val));
                }
            }
            catch (Exception e)
            {
                GXLogging.Error(log, "setcolor error", e);
                m_errAccess.setErrDes("Invalid font properties");
                m_errAccess.setErrCod((short)6);
            }
        }
Example #2
0
        public ExcelCells(IGxError errAccess, ExcelDocument document, object workBook, object selectedSheet, int rowPos, int colPos, int height, int width, bool readOnly)
        {
            doc            = document;
            m_errAccess    = errAccess;
            pWidth         = width;
            pHeight        = height;
            cntCells       = 0;
            pColPos        = colPos;
            pSelectedSheet = (ExcelWorksheet)selectedSheet;
            this.readOnly  = readOnly;

            try
            {
                pCellsRange = getExcelCell(rowPos, pColPos, pColPos + (pWidth - 1), rowPos + (pHeight - 1));
                pCells      = new ExcelRange[width * height + 1];
                string address  = pCellsRange.Address;
                int    startRow = pCellsRange.Start.Row;
                int    endRow   = pCellsRange.End.Row;
                int    startCol = pCellsRange.Start.Column;
                int    endCol   = pCellsRange.End.Column;
                for (int i = startRow; i <= endRow; i++)
                {
                    for (int j = startCol; j <= endCol; j++)
                    {
                        cntCells++;
                        pCells[cntCells] = pCellsRange[i, j];
                    }
                }
                pCellsRange.Address = address;
            }

            catch (Exception e)
            {
                GXLogging.Error(log, "ExcelCells error", e);
                m_errAccess.setErrDes("Invalid cell coordinates");
                m_errAccess.setErrCod((short)8);
            }
        }