c# Excel

pgfpwx 2008-03-31 05:34:01
各位,我在FORM中调用了Excel的打印预览,但是在关闭预览时老是提醒“是否保存Excel文件”我想迈过这步,长江支流的实现了这一功能,我也想实现,但是看不懂他程序,你们有办法吗?
...全文
72 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
tanxiaolin520 2008-04-01
  • 打赏
  • 举报
回复
好像datagridview 数据导入excel的时候都会这样,我写的也一样。不过没什么影响的,你点否就可以了啊
美丽大道 2008-04-01
  • 打赏
  • 举报
回复
Ex.DisplayAlerts = false;
美丽大道 2008-04-01
  • 打赏
  • 举报
回复
先把文档关闭了 displayAl什么的属性 设置成FALSE 就不会提示了
pgfpwx 2008-04-01
  • 打赏
  • 举报
回复
因为涉及到账务的问题,我想的是最好能一下子退出全部!能否直接控制其为"否”的?
pgfpwx 2008-03-31
  • 打赏
  • 举报
回复
程序: this.Cursor = Cursors.WaitCursor;
Microsoft.Office.Interop.Excel.Application Ex = new Microsoft.Office.Interop.Excel.Application();
//Workbook wb = Ex.Workbooks.Add(ExcelName);
Workbook wb = Ex.Workbooks.Add(@"D:\张伟\新疆建工集团账务日常处理系统\源码\SQL\Excel\lxtzd.xlt");
//Worksheet Ex = wb.Worksheets[1] as Worksheet;

//wb.Open("D:\\张伟\zj\newgrandjz\Excel\Sheet1.xlt");

//Excel.Visible = true;

//Excel.Application.Workbooks.Add(false);
Ex.Visible = true;


Ex.Cells[2, "G"] = this.etaitle1.Text;

//Excel.Cells.Font.Size = 15;
//Excel.Save("d:\tzd.xls");

Ex.Cells[4, "C"] = this.eno.Text; Ex.Cells[4, "v"] = this.edate.Text;

Ex.Cells[5, "B"] = this.ebm1.Text;
Ex.Cells[6, "B"] = this.eqj1.Text; // Excel.Cells[4, 5] = this.eyf.Text; Excel.Cells[4, 6] = this.eyf1.Text; Excel.Cells[4, 7] = this.ets.Text; Excel.Cells[4, 8] = this.ets1.Text;

Ex.Cells[8, "C"] = this.ebqw1.Text; Ex.Cells[8, "D"] = this.ebbw1.Text; Ex.Cells[8, "E"] = this.ebsw1.Text; Ex.Cells[8, "F"] = this.ebw1.Text; Ex.Cells[8, "G"] = this.ebq1.Text; Ex.Cells[8, "H"] = this.ebb1.Text; Ex.Cells[8, "I"] = this.ebs1.Text; Ex.Cells[8, "J"] = this.eby1.Text; Ex.Cells[8, "K"] = this.ebj1.Text; Ex.Cells[8, "L"] = this.ebf1.Text;

Ex.Cells[7, "N"] = this.ell1.Text;

Ex.Cells[8, "R"] = this.elqw1.Text; Ex.Cells[8, "S"] = this.elbw1.Text; Ex.Cells[8, "T"] = this.elsw1.Text; Ex.Cells[8, "U"] = this.elw1.Text; Ex.Cells[8, "V"] = this.elq1.Text; Ex.Cells[8, "W"] = this.elb1.Text; Ex.Cells[8, "X"] = this.els1.Text; Ex.Cells[8, "Y"] = this.ely1.Text; Ex.Cells[8, "Z"] = this.elj1.Text; Ex.Cells[8, "AA"] = this.elf1.Text;
Ex.Cells[9, "B"] = this.esm1.Text;
Ex.Cells[10, "B"] = this.ebz1.Text;
Ex.Cells[9, "B"] = this.eqt1.Text;

Ex.Cells[13, "N"] = this.egz1.Text;
Ex.Cells[13, "V"] = this.ezd1.Text;



//Excel.Cells[6, 1] = this.esm.Text; Excel.Cells[6, 2] = this.esm1.Text;
//Excel.Cells[7, 1] = this.ebz.Text; Excel.Cells[7, 2] = this.ebz1.Text;
//Excel.Cells[8, 1] = this.eqt.Text; Excel.Cells[8, 2] = this.eqt1.Text;

//Excel.Cells[11, 2] = this.label3.Text;
this.Cursor = Cursors.Default;
//Excel.Application.Save(@"C:\\tzd.xls");
//Workbook wb; = Excel.Workbooks;
//wb.Sheets=Excel.Sheets;
wb.PrintPreview(true);

wb = null;
Ex.Quit();
Ex = null;
System.GC.Collect();

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧