Delete Row Form Excle Sheet
Can any one help ... for how to delete a particular row form Excle Sheet.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Veeresh KumarPosted Oct 24, 2018, 3:08 AM
Bobby MilliganPosted Sep 11, 2015, 4:09 AM
Hermes CondezPosted Mar 6, 2012, 8:30 AM
assuming that you have already a workbook "wkBook"
wkSheet = (Worksheet)wkBook.Sheets[1];
// single delete
Range aRangeSingle = wkSheet.get_Range("A1", "A1");
aRangeSingle.Delete(XlDeleteShiftDirection.xlShiftUp);
// multi-delete
Range aRangeMulti = wkSheet.get_Range("A10", "A25");
aRangeMulti.Delete(XlDeleteShiftDirection.xlShiftUp);
Ankit ShivnakrPosted Mar 6, 2012, 3:42 AM
its not working
M attaching my work plz find d code and
let know whats prob.
Before this Paste excle file into D drive
Prasant JinagaPosted Mar 6, 2012, 2:57 AM
I am expecting you want to delete the row in excel in C#
If you are using microsoft Interlop services to read and write Excel file....
Then,Here is the process
string filePath = "C:\\sample.xls";
//give the path of our excel file here
clsExcel = new Microsoft.Office.Interop.Excel.ApplicationClass();
//define excel class
clsExcel.Visible = false;
//set the visible property
clsWorkbook = clsExcel.Workbooks.Open(filePath, 2, false, 5,"", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", false,true, 0, false,true,Microsoft.Office.Interop.Excel.XlCorruptLoad.xlNormalLoad);
//open the workbook for editing
clsWorksheet = (Excel.Worksheet)clsWorkbook.ActiveSheet;
//note that this will work only when you have one worksheet (which is obviously
//the active sheet), in case of multiple worksheets use the name property
Excel.Range range = clsWorksheet.get_Range("A3","A20".ToString());
//setting the range for deleting the rows
range.EntireRow.Delete(Excel.XlDirection.xlUp);
//for deleting the rows; in case of columns use: 'EntireColumn' instead of 'EntireRow'
clsWorkbook.Save();
//save the workbook
clsWorkbook.Close(false, "", false);
//close the workbook
clsExcel.Quit();
//quit the workbook
Hope it helps!!!
Thanks,
Prasant