用C#编辑后如何保存Excel文件? [英] How to Save Excel File after Editing in C#?

查看:836
本文介绍了用C#编辑后如何保存Excel文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
请帮我解决这个问题.

目的就是这样.
1.打开Excel文件(已存在)
2.将数据写入其中.
3.保存并关闭.

步骤1是使用
实现的

Hello All,
Please help me out with this.

The objective is like this.
1.Open Excel file(Already Existing)
2.Write Data To it.
3.Save it and close it.

Step 1 is achieved using

Excel.Workbook CreateXLFile = StartExcel.Workbooks.Open(
FileName,
0,
true,
5,
"",
"",
true,
Excel.XlPlatform.xlWindows,
"\t",
false,
false,
0,
true,
1,
0);

Excel.Worksheet SelectXLSheet = (Microsoft.Office.Interop.Excel.Worksheet)CreateXLFile.ActiveSheet;



步骤2是使用
实现的



Step 2 is achieved using

SelectXLSheet.Cells[Cell, Row] = Data;



使用workbook.save()方法尝试了步骤3.
但这不起作用.
请帮助我解决如何仅保存方法以保存文件而不使用saveas方法的问题.



Step 3 is tried using workbook.save() method.
But this does not work.
Please help me out with how i can only save method to save file rather than use saveas method.

推荐答案

在其中放置一个try/catch块和一个调试断点捕获块.到那时,您可能会发现为什么它不起作用".
Put a try/catch block around it and a debug breakpoint inside the catch block. At that point, you''ll probably find out why it "doesn''t work".


这篇关于用C#编辑后如何保存Excel文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆