
Microsoft.Office.Interop.Excel问题,如何将文件另存为
Microsoft.Office.Interop.Excel.ApplicationClassexcel=newMicrosoft.Office.Interop.Exce...
Microsoft.Office.Interop.Excel.ApplicationClass excel = new Microsoft.Office.Interop.Excel.ApplicationClass();
excel.Application.Workbooks.Add(true);
excel.Visible = true;
for (int i = 0; i < this.eInfo.ColumnCount; i++)
{
excel.Cells[1, i + 1] = this.eInfo.Columns[i].HeaderText;
}
for (int i = 0; i < this.eInfo.RowCount - 1; i++)
{
for (int j = 0; j < this.eInfo.ColumnCount; j++)
{
excel.Cells[i + 2, j + 1] = this.eInfo[j, i].Value.ToString();
excel.Columns.AutoFit();//自动适应
}
}
这段代码是直接打开excel的,我想改成在导出excel时,将excel另存为。要怎么做啊 展开
excel.Application.Workbooks.Add(true);
excel.Visible = true;
for (int i = 0; i < this.eInfo.ColumnCount; i++)
{
excel.Cells[1, i + 1] = this.eInfo.Columns[i].HeaderText;
}
for (int i = 0; i < this.eInfo.RowCount - 1; i++)
{
for (int j = 0; j < this.eInfo.ColumnCount; j++)
{
excel.Cells[i + 2, j + 1] = this.eInfo[j, i].Value.ToString();
excel.Columns.AutoFit();//自动适应
}
}
这段代码是直接打开excel的,我想改成在导出excel时,将excel另存为。要怎么做啊 展开
1个回答
展开全部
excel.ActiveWorkbook.SaveAs(
[Filename], [FileFormat], [Password], [WriteResPassword], [ReadOnlyRecommended], [CreateBackup], [AccessMode As XlSaveAsAccessMode = xlNoChange], [ConflictResolution], [AddToMru], [TextCodepage], [TextVisualLayout], [Local])
[Filename], [FileFormat], [Password], [WriteResPassword], [ReadOnlyRecommended], [CreateBackup], [AccessMode As XlSaveAsAccessMode = xlNoChange], [ConflictResolution], [AddToMru], [TextCodepage], [TextVisualLayout], [Local])
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询