Beispiel #1
0
        public string IsInNamedRange(ExcelWorksheet sheet, int Row, int Column)
        {
            string chunk = "";
            string refersTo = "";
            string min = "", max = "";
            int minRow = 0, minCol = 0;
            int maxRow = 0, maxCol = 0;

            foreach (NamedRange range in _Names.Collection)
            {
                refersTo = range.RefersTo.Substring(0, range.RefersTo.IndexOf("!"));
                if (refersTo.ToLower() == sheet.Name.ToLower())
                {
                    chunk = range.RefersTo.Substring(range.RefersTo.IndexOf("!") + 1);
                    min = chunk.Split(':')[0];
                    max = chunk.Split(':')[1];

                    minRow = int.Parse(min.Substring(1, min.IndexOf('C') - 1));
                    minCol = int.Parse(min.Substring(min.IndexOf('C') + 1));
                    maxRow = int.Parse(max.Substring(1, max.IndexOf('C') - 1));
                    maxCol = int.Parse(max.Substring(max.IndexOf('C') + 1));

                    if ((Row >= minRow && Row <= maxRow) && (Column >= minCol && Column <= maxCol))
                    {
                        return range.Name;
                    }
                }
            }

            return "";
        }
Beispiel #2
0
        public int GetExpandedColumnCount(ExcelWorksheet worksheet)
        {
            int index = 0;
            int count = 0;

            foreach (WorksheetRow row in worksheet.Table.Rows.Collection)
            {
                count = 0;
                foreach (WorksheetCell cell in row.Cells.Collection)
                {
                    count++;
                    if (cell.Index > 0)
                    {
                        if (cell.Index > index)
                        {
                            index = cell.Index;
                        }
                    }
                }
                if (count > index)
                {
                    index = count;
                }
            }

            if (index > count)
            {
                return index;
            }
            else
            {
                return count;
            }
        }
Beispiel #3
0
        public int GetExpandedRowCount(ExcelWorksheet worksheet)
        {
            int count = 0;
            int index = 0;

            foreach (WorksheetRow row in worksheet.Table.Rows.Collection)
            {
                count++;
                if (row.Index > 0)
                {
                    if (row.Index > index)
                    {
                        index = row.Index;
                        count = row.Index;
                    }
                }
            }

            if (index > count)
            {
                return index;
            }
            else
            {
                return count;
            }
        }
Beispiel #4
0
 public ExcelWorksheet Add(string TabName)
 {
     ExcelWorksheet worksheet = new ExcelWorksheet();
     TabName = CheckWorksheetName(TabName);
     worksheet.Name = TabName;
     _Worksheets.Add(worksheet);
     return worksheet;
 }