Exemple #1
0
 internal ExcelCell(IExcelWorksheet workSheet, int row, int column)
 {
     this._formatId = -1;
     this._owner    = workSheet;
     this._row      = row;
     this._column   = column;
 }
Exemple #2
0
        public bool GetCells(short sheet, List <IExcelCell> cells)
        {
            if (cells == null)
            {
                throw new ArgumentNullException("cells");
            }
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            if (worksheet == null)
            {
                return(false);
            }
            List <IExcelRow> nonEmptyRows = worksheet.GetNonEmptyRows();

            for (int i = 0; i < nonEmptyRows.Count; i++)
            {
                IExcelRow         row           = nonEmptyRows[i];
                List <IExcelCell> nonEmptyCells = worksheet.GetNonEmptyCells(row.Index);
                if (nonEmptyCells.Count > 0)
                {
                    cells.AddRange((IEnumerable <IExcelCell>)nonEmptyCells);
                }
            }
            return(true);
        }
Exemple #3
0
        public void GetOutlineDirection(int sheet, ref bool summaryColumnsRightToDetail, ref bool summaryRowsBelowDetail)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            summaryColumnsRightToDetail = worksheet.SummaryColumnsToRightOfDetail;
            summaryRowsBelowDetail      = worksheet.SummaryRowsBelowDetail;
        }
Exemple #4
0
        public bool SetRowInfo(short sheet, int row, int columnFirstDef, int columnLastDefPlus1, short ixf, double height, byte outlineLevel, bool collapsed, bool hidden, bool unSynced, bool ghostDirty)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            if (worksheet.RowCount <= row)
            {
                worksheet.RowCount = row;
            }
            IExcelRow row2 = worksheet.GetRow(row, true);

            if (row2 == null)
            {
                return(false);
            }
            if (ghostDirty)
            {
                row2.SetFormatId(ixf);
            }
            row2.Collapsed    = collapsed;
            row2.OutLineLevel = outlineLevel;
            if (!double.IsNaN(height))
            {
                row2.Height = height;
            }
            row2.Visible = !hidden;
            return(true);
        }
Exemple #5
0
        public void SetSelection(short sheet, PaneType paneType, int rowActive, int columnActive, int refCount, List <int> rowFirst, List <int> rowLast, List <int> colFirst, List <int> colLast)
        {
            int             num       = rowFirst.Count;
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            for (int i = 0; i < num; i++)
            {
                int            row    = rowFirst[i];
                int            num4   = rowLast[i];
                int            column = colFirst[i];
                int            num6   = colLast[i];
                SelectionRange range  = new SelectionRange(row, column, (row == -1) ? 0 : ((num4 - row) + 1), (column == -1) ? 0 : ((num6 - column) + 1))
                {
                    activePaneType = paneType
                };
                if ((worksheet.Selections.Count != 1) || (worksheet.Selections[0] != range))
                {
                    worksheet.Selections.Add(range);
                }
            }
            int num7 = Math.Max(0, Math.Min(rowActive, worksheet.RowCount - 1));
            int num8 = Math.Max(0, Math.Min(columnActive, worksheet.ColumnCount - 1));

            worksheet.ActiveRowIndex    = (worksheet.RowCount > 0) ? num7 : -1;
            worksheet.ActiveColumnIndex = (worksheet.ColumnCount > 0) ? num8 : -1;
        }
Exemple #6
0
        public void SetArrayFormula(int sheet, int rowFirst, int rowLast, short colFirst, short colLast, IExcelFormula arrayFormula)
        {
            if (arrayFormula == null)
            {
                throw new ArgumentNullException("arrayFormula");
            }
            if (!arrayFormula.IsArrayFormula)
            {
                throw new ArgumentException(ResourceHelper.GetResourceString("arrayFormulaError"));
            }
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];
            ExcelCellRange  range     = new ExcelCellRange {
                Row        = rowFirst,
                RowSpan    = (rowLast - rowFirst) + 1,
                Column     = colFirst,
                ColumnSpan = (colLast - colFirst) + 1
            };

            for (int i = rowFirst; i <= rowLast; i++)
            {
                for (int j = colFirst; j <= colLast; j++)
                {
                    IExcelCell cell = worksheet.GetCell(i, j, true);
                    cell.CellFormula = arrayFormula;
                    cell.CellFormula.ArrayFormulaRange = range;
                    cell.IsArrayFormula = true;
                    cell.CellType       = CellType.Array;
                }
            }
        }
Exemple #7
0
        public void GetFrozen(short sheet, ref int frozenRowCount, ref int frozenColumnCount, ref int frozenTrailingRowCount, ref int frozenTrailingColumnCount)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            frozenRowCount    = worksheet.FrozenRowCount;
            frozenColumnCount = worksheet.FrozenColumnCount;
        }
Exemple #8
0
 protected BaseExcelFormControlInfo([NotNull] IExcelWorksheet excelWorksheet, [NotNull] Control control, [NotNull] ControlPropertiesPart controlPropertiesPart, [NotNull] VmlDrawingPart vmlDrawingPart)
 {
     this.excelWorksheet   = excelWorksheet;
     Control               = control;
     GlobalVmlDrawingPart  = vmlDrawingPart;
     ControlPropertiesPart = controlPropertiesPart;
 }
Exemple #9
0
        public void SetColumnInfo(short sheet, short colFirst, short colLast, short ixf, double width, bool hidden, byte outlineLevel, bool collapsed)
        {
            if (colFirst < 0)
            {
                throw new ArgumentOutOfRangeException("");
            }
            if (colLast < 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (width < 0.0)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (colLast < colFirst)
            {
                throw new ArgumentOutOfRangeException();
            }
            IExcelWorksheet workSheet = this._workbook.Worksheets[sheet];

            workSheet.ColumnCount = Math.Max(workSheet.ColumnCount, colLast);
            for (int i = colFirst; i <= colLast; i++)
            {
                ExcelColumn column = new ExcelColumn(workSheet)
                {
                    Index = i,
                    Width = width
                };
                column.SetFormatId(ixf);
                column.Visible      = !hidden;
                column.Collapsed    = collapsed;
                column.OutLineLevel = outlineLevel;
                workSheet.SetColumn(i, column);
            }
        }
Exemple #10
0
        private void FillCells(IExcelWorksheet excelWorksheet)
        {
            excelWorksheet.GetCells(0, 0).Value = "Title";
            excelWorksheet.GetCells(0, 1).Value = "Subtitle";

            excelWorksheet.GetCells("A2:D5").Value = "Big merged cell";
        }
Exemple #11
0
 public void SetExcelSheetTabColor(int sheet, IExcelColor color)
 {
     if (color != null)
     {
         IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];
         worksheet.SheetTabColor = color;
     }
 }
Exemple #12
0
        public void SetRowColumnGutters(short sheetIndex, short dxRwGut, short dyColGut, short iLevelRwMac, short iLevelColMac)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheetIndex];

            worksheet.RowGutter             = dxRwGut;
            worksheet.RowMaxOutlineLevel    = iLevelRwMac;
            worksheet.ColumnGutter          = dyColGut;
            worksheet.ColumnMaxOutlineLevel = iLevelColMac;
        }
Exemple #13
0
 public List <IExcelRow> GetNonEmptyRows(short sheet)
 {
     if (this.ValidateWorkbook(sheet))
     {
         IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];
         return(worksheet.GetNonEmptyRows());
     }
     return(null);
 }
Exemple #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Dt.Xls.ExcelCell" /> class.
 /// </summary>
 /// <param name="workSheet">The owner <see cref="T:Dt.Xls.IExcelWorksheet" /> instance</param>
 public ExcelCell(IExcelWorksheet workSheet)
 {
     this._formatId = -1;
     if (workSheet == null)
     {
         throw new ArgumentNullException("workSheet");
     }
     this._owner = workSheet;
 }
Exemple #15
0
 public void GetGutters(short sheet, ref int iLevelRwMac, ref int iLevelColMac)
 {
     if (this.ValidateWorkbook(sheet))
     {
         IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];
         iLevelRwMac  = worksheet.RowMaxOutlineLevel;
         iLevelColMac = worksheet.ColumnMaxOutlineLevel;
     }
 }
Exemple #16
0
        public void SetCellNote(short sheet, int row, int column, bool stickyNote, string note)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            worksheet[row, column].Note = note;
            if (stickyNote)
            {
                worksheet[row, column].NoteStyle = ExcelNoteStyle.StickyNote;
            }
        }
Exemple #17
0
        public void SetDisplayElements(short sheet, bool dispFormula, bool dispZeros, bool showGridLine, bool dispRowColHdr, bool rightToLeftColumns)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            worksheet.ShowGridLines      = showGridLine;
            worksheet.ShowHeaders        = dispRowColHdr;
            worksheet.ShowFormulas       = dispFormula;
            worksheet.ShowZeros          = dispZeros;
            worksheet.RightToLeftColumns = rightToLeftColumns;
        }
Exemple #18
0
        public void GetDisplayElements(short sheet, ref bool dispFormula, ref bool dispZeros, ref bool dispGrid, ref bool dispRowColHdr, ref bool rightToLeftColumns)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            dispGrid           = worksheet.ShowGridLines;
            dispRowColHdr      = worksheet.ShowHeaders;
            dispFormula        = worksheet.ShowFormulas;
            dispZeros          = worksheet.ShowZeros;
            rightToLeftColumns = worksheet.RightToLeftColumns;
        }
Exemple #19
0
        public bool GetVerticalCenter(short sheet, ref bool center)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            if (worksheet.PrintSettings != null)
            {
                center = worksheet.PrintSettings.Options.VerticalCentered;
            }
            return(true);
        }
Exemple #20
0
        public bool GetPrintHeaders(short sheet, ref bool print)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            if (worksheet.PrintSettings != null)
            {
                return(false);
            }
            return(true);
        }
Exemple #21
0
        public void SetPrintPageSetting(short sheet, IExcelPrintPageSetting pageSetting)
        {
            if (pageSetting == null)
            {
                throw new ArgumentNullException("pageSetting");
            }
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            worksheet.PrintSettings.PageSetting = pageSetting;
        }
Exemple #22
0
 /// <summary>
 /// Initialize a new instance of <see cref="T:Dt.Xls.ExcelColumn" />.
 /// </summary>
 /// <param name="workSheet">The owner <see cref="T:Dt.Xls.IExcelWorksheet" /> instance</param>
 public ExcelColumn(IExcelWorksheet workSheet)
 {
     if (workSheet == null)
     {
         throw new ArgumentNullException("workSheet");
     }
     this._owner    = workSheet;
     this.Width     = 8.0;
     this.Collapsed = false;
     this.Visible   = true;
 }
Exemple #23
0
 /// <summary>
 /// Initialize a new instance of <see cref="T:Dt.Xls.ExcelRow" />.
 /// </summary>
 /// <param name="workSheet">The owner <see cref="T:Dt.Xls.IExcelWorksheet" /> instance</param>
 public ExcelRow(IExcelWorksheet workSheet)
 {
     if (workSheet == null)
     {
         throw new ArgumentNullException("workSheet");
     }
     this._owner    = workSheet;
     this.Collapsed = false;
     this.Height    = 15.0;
     this.Visible   = true;
 }
        public void CopyDataValidationsFrom([NotNull] IExcelWorksheet template)
        {
            var templateWorksheet = ((ExcelWorksheet)template).worksheet;
            var dataValidations   = templateWorksheet.GetFirstChild <DataValidations>();

            if (dataValidations == null)
            {
                return;
            }
            InsertWorksheetChild(worksheet, (DataValidations)dataValidations.CloneNode(true));
        }
        public void CopyWorksheetExtensionListFrom(IExcelWorksheet template)
        {
            var templateWorksheet      = ((ExcelWorksheet)template).worksheet;
            var worksheetExtensionList = templateWorksheet.GetFirstChild <WorksheetExtensionList>();

            if (worksheetExtensionList == null)
            {
                return;
            }
            worksheet.AppendChild(worksheetExtensionList.CloneNode(true));
        }
Exemple #26
0
        public void CopyDataValidationsFrom([NotNull] IExcelWorksheet template)
        {
            var templateWorksheet = ((ExcelWorksheet)template).worksheet;
            var dataValidations   = templateWorksheet.GetFirstChild <DataValidations>();

            if (dataValidations == null)
            {
                return;
            }
            worksheet.InsertBefore(dataValidations.CloneNode(true), worksheet.GetFirstChild <PageMargins>());
        }
Exemple #27
0
        public void SetDefaultColumnWidth(short sheet, double baseColumnWidth, double?defaultColumnWidth)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            if (defaultColumnWidth.HasValue && defaultColumnWidth.HasValue)
            {
                worksheet.DefaultColumnWidth = defaultColumnWidth.Value;
            }
            else
            {
                worksheet.DefaultColumnWidth = baseColumnWidth;
            }
        }
Exemple #28
0
        public void SetGridlineColor(short sheet, IExcelColor color)
        {
            if (color == null)
            {
                throw new ArgumentNullException("color");
            }
            if (color.ColorType != ExcelColorType.Indexed)
            {
                throw new ArgumentException(ResourceHelper.GetResourceString("gridlineColorTypeError"));
            }
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            worksheet.GridLineColor = color;
        }
Exemple #29
0
        public void SetPrintPageMargin(short sheet, IExcelPrintPageMargin printPageMagin)
        {
            if (printPageMagin == null)
            {
                throw new ArgumentNullException("printPageMagin");
            }
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            if (worksheet.PrintSettings == null)
            {
                worksheet.PrintSettings = new ExcelPrintSettings();
            }
            worksheet.PrintSettings.Margin = printPageMagin;
        }
Exemple #30
0
        public bool GetRowPageBreaks(short sheet, List <short> pageBreaks)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];
            ushort          num       = (ushort)Math.Min(0xffff, worksheet.RowCount);

            for (short i = 0; i < num; i++)
            {
                IExcelRow row = worksheet.GetRow(i, false);
                if ((row != null) && row.PageBreak)
                {
                    pageBreaks.Add(i);
                }
            }
            return(true);
        }