Axspreadsheet的例子
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 914 2010-03-16 11:02 MOAWindowsapp.config
文件 151552 2010-03-17 11:04 MOAWindowsinDebugAxInterop.OWC11.dll
文件 45056 2010-03-17 11:04 MOAWindowsinDebugAxInterop.SHDocVw.dll
文件 1093632 2010-01-31 19:12 MOAWindowsinDebugInterop.Excel.dll
文件 217088 2010-02-10 13:38 MOAWindowsinDebugInterop.Microsoft.Office.Core.dll
文件 131072 2010-03-17 11:04 MOAWindowsinDebugInterop.SHDocVw.dll
文件 57344 2010-02-24 14:14 MOAWindowsinDebugInterop.VBIDE.dll
文件 135168 2010-03-18 10:38 MOAWindowsinDebugMOAWindows.exe
文件 914 2010-03-16 11:02 MOAWindowsinDebugMOAWindows.exe.config
文件 163328 2010-03-18 10:38 MOAWindowsinDebugMOAWindows.pdb
文件 5632 2005-11-11 22:25 MOAWindowsinDebugMOAWindows.vshost.exe
文件 914 2010-03-16 11:02 MOAWindowsinDebugMOAWindows.vshost.exe.config
文件 1496576 2008-01-09 08:00 MOAWindowsinDebugshdocvw.dll
文件 27732 2010-03-17 17:00 MOAWindowsinDebug emp.xml
目录 0 2010-03-17 17:00 MOAWindowsinDebug
....... 13277 2010-03-16 10:18 MOAWindowsinDebugtemp.xls
文件 23632 2010-03-16 19:52 MOAWindowsinDebugtemp.xml
目录 0 2010-03-16 19:52 MOAWindowsin
文件 30350 2010-03-15 16:26 MOAWindowsExcelProgress.cs
文件 3495 2010-03-15 10:58 MOAWindowsForm1.cs
文件 7692 2010-03-15 10:58 MOAWindowsForm1.Designer.cs
文件 5814 2010-03-15 10:58 MOAWindowsForm1.resx
文件 17173 2010-03-18 11:12 MOAWindowsForm2.cs
文件 12245 2010-03-18 09:57 MOAWindowsForm2.Designer.cs
文件 10995 2010-03-18 09:57 MOAWindowsForm2.resx
文件 9844 2010-03-16 11:23 MOAWindowsMOAWindows.csproj
文件 2705 2010-03-08 20:11 MOAWindowsMSExcle.cs
文件 151552 2010-03-17 11:04 MOAWindowsobjDebugAxInterop.OWC11.dll
文件 45056 2010-03-17 11:04 MOAWindowsobjDebugAxInterop.SHDocVw.dll
文件 409600 2010-03-05 17:17 MOAWindowsobjDebugInterop.Microsoft.Office.Core.dll
............此处省略48个文件信息
using System;
using System.Data;
using System.Reflection;
using System.IO;
using Microsoft.Office.Core;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
namespace MOAWindows
{
public class ExcelProgress
{
#region Variables
private Excel.Application excelApplication = null;
private Excel.Workbooks excelWorkBooks = null;
private Excel.Workbook excelWorkBook = null;
private Excel.Worksheet excelWorkSheet = null;
private Excel.Range excelRange = null;//Excel Range object多种用途
private Excel.Range excelCopySourceRange = null;//Excel Range object
private int excelActiveWorkSheetIndex; //活动工作表索引
private string excelOpenFileName = ““; //操作Excel的路径
private string excelSaveFileName = ““; //保存Excel的路径
#endregion
#region Properties
public int ActiveSheetIndex
{
get
{
return excelActiveWorkSheetIndex;
}
set
{
excelActiveWorkSheetIndex = value;
}
}
public string OpenFileName
{
get
{
return excelOpenFileName;
}
set
{
excelOpenFileName = value;
}
}
public string SaveFileName
{
get
{
return excelSaveFileName;
}
set
{
excelSaveFileName = value;
}
}
#endregion
///
/// 构造函数;
///
public ExcelProgress()
{
excelApplication = null;//Excel Application object
excelWorkBooks = null;//Workbooks
excelWorkBook = null;//Excel Workbook object
excelWorkSheet = null;//Excel Worksheet object
ActiveSheetIndex = 1; //默认值活动工作簿为第一个;设置活动工作簿请参阅SetActiveWorkSheet()
}
///
/// 以excelOpenFileName为模板新建Excel文件
///
public bool OpenExcelFile()
{
if (excelApplication != null) CloseExcelApplication();
//检查文件是否存在
if (excelOpenFileName == ““)
{
throw new Exception(“请选择文件!“);
}
if (!File.Exists(excelOpenFileName))
{
throw new Exception(excelOpenFileName + “该文件不存在!“);//该异常如何处理,由什么处理????
}
try
{
excelApplication = new Excel.ApplicationClass();
excelWorkBooks = excelApplication.Workbooks;
excelWorkBook = ((Excel.Workbook)excelWorkBooks.Open(excelOpenFileName Missing.Value Missing.Value Missing.Value Missing.Value Missing.Value Missing.Value Missing.Value Missing.Value Missing.Value Missing.
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 914 2010-03-16 11:02 MOAWindowsapp.config
文件 151552 2010-03-17 11:04 MOAWindowsinDebugAxInterop.OWC11.dll
文件 45056 2010-03-17 11:04 MOAWindowsinDebugAxInterop.SHDocVw.dll
文件 1093632 2010-01-31 19:12 MOAWindowsinDebugInterop.Excel.dll
文件 217088 2010-02-10 13:38 MOAWindowsinDebugInterop.Microsoft.Office.Core.dll
文件 131072 2010-03-17 11:04 MOAWindowsinDebugInterop.SHDocVw.dll
文件 57344 2010-02-24 14:14 MOAWindowsinDebugInterop.VBIDE.dll
文件 135168 2010-03-18 10:38 MOAWindowsinDebugMOAWindows.exe
文件 914 2010-03-16 11:02 MOAWindowsinDebugMOAWindows.exe.config
文件 163328 2010-03-18 10:38 MOAWindowsinDebugMOAWindows.pdb
文件 5632 2005-11-11 22:25 MOAWindowsinDebugMOAWindows.vshost.exe
文件 914 2010-03-16 11:02 MOAWindowsinDebugMOAWindows.vshost.exe.config
文件 1496576 2008-01-09 08:00 MOAWindowsinDebugshdocvw.dll
文件 27732 2010-03-17 17:00 MOAWindowsinDebug emp.xm
目录 0 2010-03-17 17:00 MOAWindowsinDebug
....... 13277 2010-03-16 10:18 MOAWindowsinDebugtemp.xls
文件 23632 2010-03-16 19:52 MOAWindowsinDebugtemp.xm
目录 0 2010-03-16 19:52 MOAWindowsin
文件 30350 2010-03-15 16:26 MOAWindowsExcelProgress.cs
文件 3495 2010-03-15 10:58 MOAWindowsForm1.cs
文件 7692 2010-03-15 10:58 MOAWindowsForm1.Designer.cs
文件 5814 2010-03-15 10:58 MOAWindowsForm1.resx
文件 17173 2010-03-18 11:12 MOAWindowsForm2.cs
文件 12245 2010-03-18 09:57 MOAWindowsForm2.Designer.cs
文件 10995 2010-03-18 09:57 MOAWindowsForm2.resx
文件 9844 2010-03-16 11:23 MOAWindowsMOAWindows.csproj
文件 2705 2010-03-08 20:11 MOAWindowsMSExcle.cs
文件 151552 2010-03-17 11:04 MOAWindowsobjDebugAxInterop.OWC11.dll
文件 45056 2010-03-17 11:04 MOAWindowsobjDebugAxInterop.SHDocVw.dll
文件 409600 2010-03-05 17:17 MOAWindowsobjDebugInterop.Microsoft.Office.Core.dll
............此处省略48个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)