C#操作EXCEL 删除列如何实现
Excel.ApplicationExlApp=newExcel.Application();ExlApp.Visible=true;objectoMissiong=Sy...
Excel.Application ExlApp = new Excel.Application();
ExlApp.Visible = true;
object oMissiong = System.Reflection.Missing.Value;
ExlApp.Workbooks._Open(filename1, oMissiong, oMissiong, oMissiong, oMissiong, oMissiong, oMissiong,
oMissiong, oMissiong, oMissiong, oMissiong, oMissiong, oMissiong);//, oMissiong);//, oMissiong);
Excel.Workbook Workbook1 = null;
Excel.Worksheet Worksheet1 = null;
Workbook1 = ExlApp.Workbooks[1];
Worksheet1 = (Excel.Worksheet)Workbook1.Worksheets[1];
Worksheet1.Columns.Delete(1);
这个把所有的列都删除了
谁能告诉我删除第一列 或者 第n列怎么做呢?
Worksheet1.Columns[1].Delete();
Worksheet1.Columns(1).Delete();我都试过不行 展开
ExlApp.Visible = true;
object oMissiong = System.Reflection.Missing.Value;
ExlApp.Workbooks._Open(filename1, oMissiong, oMissiong, oMissiong, oMissiong, oMissiong, oMissiong,
oMissiong, oMissiong, oMissiong, oMissiong, oMissiong, oMissiong);//, oMissiong);//, oMissiong);
Excel.Workbook Workbook1 = null;
Excel.Worksheet Worksheet1 = null;
Workbook1 = ExlApp.Workbooks[1];
Worksheet1 = (Excel.Worksheet)Workbook1.Worksheets[1];
Worksheet1.Columns.Delete(1);
这个把所有的列都删除了
谁能告诉我删除第一列 或者 第n列怎么做呢?
Worksheet1.Columns[1].Delete();
Worksheet1.Columns(1).Delete();我都试过不行 展开
1个回答
展开全部
protected bool DeleteCol(int ColNum)
{
((Excel.Range) m_objSheet.Cells[1,ColNum]).Select();
((Excel.Range) m_objSheet.Cells[1,ColNum]).EntireColumn.Delete(0);
//this.m_objSheet.UsedRange.Columns.Delete(ColNum);
return true;
}
{
((Excel.Range) m_objSheet.Cells[1,ColNum]).Select();
((Excel.Range) m_objSheet.Cells[1,ColNum]).EntireColumn.Delete(0);
//this.m_objSheet.UsedRange.Columns.Delete(ColNum);
return true;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |