using System
using System
using Excel = Microsoft
using System
using System
namespace OfficeManager
{
public class ExcelClass : IDisposable
{
private Excel
private Excel
public Excel
private object missing = System
public ExcelClass()
{
if (m_ExcelApplication == null)
{
m_ExcelApplication = new Excel
}
}
~ExcelClass()
{
try
{
if (m_ExcelApplication != null)
m_ExcelApplication
}
catch (Exception ex)
{
Debug
}
}
/// <summary>
/// 獲取或設置當前工作表
/// </summary>
public int CurrentWorksheetIndex
{
set
{
if (value <=
throw new Exception(
else
{
object index = value;
m_Worksheet = m_Workbook
}
}
}
/// <summary>
/// 打開一個Excel工作薄
/// </summary>
/// <param name=
public void OpenWorkbook(string fileName)
{
m_Workbook = m_ExcelApplication
missing
if (m_Workbook
{
object index =
m_Worksheet = m_Workbook
}
}
/// <summary>
/// 保存數據
/// </summary>
public void Save()
{
if (m_Workbook != null)
{
m_Workbook
}
}
/// <summary>
/// 關閉文檔
/// </summary>
/// <param name=
public void Close(bool isSave)
{
this
object obj_Save = isSave;
if (m_Workbook != null)
m_Workbook
}
/// <summary>
/// 設置當前工作表中某單元格的值
/// </summary>
/// <param name=
/// <param name=
public void SetCellValue(string cellIndex
{
if (m_Worksheet != null)
{
object cell
Excel
if (range != null)
{
range
}
}
}
/// <summary>
/// 合並單元格
/// </summary>
/// <param name=
/// <param name=
public void Merge(string cellIndex
{
if (m_Worksheet != null)
{
object cell
object cell
Excel
range
}
}
/// <summary>
/// 將當前工作表中的表格數據復制到剪切板
/// </summary>
public void Copy()
{
if (m_Worksheet != null)
{
try
{
m_Worksheet
}
catch { }
m_Worksheet
}
}
/// <summary>
/// 清空剪切板
/// </summary>
public void ClearClipboard()
{
Clipboard
}
#region IDisposable 成員
public void Dispose()
{
try
{
if (m_ExcelApplication != null)
{
this
m_ExcelApplication
m_ExcelApplication = null;
}
}
catch (Exception ex)
{
Debug
}
}
#endregion
}
}
From:http://tw.wingwit.com/Article/program/net/201311/12085.html