using
System;
using
System.Collections.Generic;
using
System.Text;
using
Excel1 = Microsoft.Office.Interop.Excel;
namespace
Removing_rows_from_existing_XLS
{ object misValue = System.Reflection.Missing.Value;
Excel1.Application
xlApp;
Excel1.Workbook
xlWorkBook;
Excel1.Worksheet
xlWorkSheet;
xlApp = new
Excel1.Application();
xlWorkBook = xlApp.Workbooks.Add(1);
xlWorkSheet = (Excel1.Worksheet)xlWorkBook.Worksheets.get_Item(1);
Excel1.Range ChartRange;
ChartRange = xlWorkSheet.get_Range((object)xlWorkSheet.Cells[1, First cell], (object)xlWorkSheet.Cells[5, Last cell]);
//Delete
rows
xlWorkSheet.Range[Startrows
cell, End rows cell]. Rows .Delete(misValue);
//or
xlWorkSheet.
ChartRange .Rows .Delete(misValue);
//Delete
Columns
xlWorkSheet.Range[Startrows
cell, End rows cell]. Cell.Delete(misValue);
//or
xlWorkSheet.
ChartRange .Cell.Delete(misValue);
}
//Result
No comments:
Post a Comment