如何使用Excel互操作删除Excel文件的第一行? [英] How to delete the first row of an excel file using Excel interop?
本文介绍了如何使用Excel互操作删除Excel文件的第一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一些有关如何删除excel文件中第一行并在此之后将剩余单元向上移动的想法.有什么想法吗?
I need some ideas on how to delete the first row in a excel file and shift the remaining cells up after that. Any ideas??
推荐答案
您可以在此处查看解决方案
删除Excel行 [
You can view the solution here
Delete an Excel row[^]
尝试使用以下代码:
Hi, have a try with the following codes:
Excel.Application myApp;
Excel.Workbook myWorkBook;
Excel.Worksheet myWorkSheet;
Excel.Range range;
myApp = new Excel.Application();
myWorkBook = myApp.Workbooks.Open("D:\\test.xls", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false , 0, true, 1, 0);
myWorkSheet = (Excel.Worksheet)myWorkBook.Worksheets.get_Item(1);
range = (Excel.Range)myWorkSheet.Application.Rows[1, Type.Missing];
range.Select();
range.Delete(Excel.XlDirection.xlUp);
myWorkBook.Close(true);
myApp.Quit();
注意使用Excel = Microsoft.Office.Interop.Excel;并最终释放对象.
以下是您可能会使用的一些Excel技能的摘要.请检查是否需要.
总结C#控件Excel技能 [
Note using Excel = Microsoft.Office.Interop.Excel; and release the object finally.
The following is a summary of some Excel skills you may use. Please have a check if you would like to.
Summarize C# Control Excel Skills[^]
这篇关于如何使用Excel互操作删除Excel文件的第一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文