Esempio n. 1
0
        public string UpdateRange(string workBookFilename, string sheetName, int row, int col, string value)
        {
            string         retval         = "";
            int            workBookIndex  = GetWorkBookIndex(workBookFilename);
            ExcelWorkBook  wb             = excelWorkBooksList[workBookIndex];
            int            workSheetIndex = GetWorkSheetIndex(wb, sheetName);
            ExcelWorkSheet ws             = wb.ExcelWorkSheets[workSheetIndex];
            Worksheet      theWS          = ws.excelWorkSheet;
            Range          theRange       = (Range)theWS.Cells[row, col];

            theRange.Value = value;
            retval         = theRange.Address;
            return(retval);
        }
Esempio n. 2
0
        public string InsertRow(string workBookFilename, string sheetName, int RowBefore)
        {
            string         retval         = "";
            int            workBookIndex  = GetWorkBookIndex(workBookFilename);
            ExcelWorkBook  wb             = excelWorkBooksList[workBookIndex];
            int            workSheetIndex = GetWorkSheetIndex(wb, sheetName);
            ExcelWorkSheet ws             = wb.ExcelWorkSheets[workSheetIndex];
            Worksheet      theWS          = ws.excelWorkSheet;
            Range          theRows        = theWS.UsedRange.Rows;//[.Rows[1, 1];//.Rows[RowBefore, 1];
            Range          theRow         = ((Range)theRows[RowBefore + 1]).EntireRow;

            if ((bool)theRow.Insert(XlDirection.xlDown, XlInsertFormatOrigin.xlFormatFromLeftOrAbove))
            {
                Range newRow = ((Range)theRows[RowBefore + 1]).EntireRow;
                retval = newRow.Address;
            }

            return(retval);
        }