Esempio n. 1
0
        public static ParameterCollection Parse(string templatePath)
        {
            ParameterCollection workbookParameter = new ParameterCollection();
            IWorkbook           workbook          = NPOIHelper.LoadWorkbook(templatePath);

            foreach (ISheet sheet in workbook)
            {
                foreach (IRow row in sheet)
                {
                    foreach (ICell cell in row.Cells)
                    {
                        if (cell.CellType.Equals(CellType.String))
                        {
                            string          cellText = cell.StringCellValue;
                            MatchCollection matches  = new Regex(@"(?<=\$\[)([\w]*)(?=\])").Matches(cellText);
                            foreach (Match match in matches)
                            {
                                workbookParameter[sheet.SheetName, match.Value] = new Point(cell.RowIndex, cell.ColumnIndex);
                            }
                        }
                    }
                }
            }
            return(workbookParameter);
        }
Esempio n. 2
0
        public static WorkbookParameterContainer Parse(string templatePath)
        {
            var       workbookParameterContainer = new WorkbookParameterContainer();
            IWorkbook workbook = NPOIHelper.LoadWorkbook(templatePath);

            foreach (ISheet sheet in workbook)
            {
                workbookParameterContainer[sheet.SheetName] = new SheetParameterContainer
                {
                    SheetName = sheet.SheetName
                };
                foreach (IRow row in sheet)
                {
                    foreach (ICell cell in row.Cells)
                    {
                        if (cell.CellType.Equals(CellType.String))
                        {
                            MatchCollection matches = new Regex(@"(?<=\$\[)([\w]*)(?=\])").Matches(cell.StringCellValue);
                            foreach (Match match in matches)
                            {
                                workbookParameterContainer[sheet.SheetName][match.Value] = new Parameter
                                {
                                    Name        = match.Value,
                                    RowIndex    = cell.RowIndex,
                                    ColumnIndex = cell.ColumnIndex
                                };
                            }
                        }
                    }
                }
            }
            return(workbookParameterContainer);
        }