using Excel;
endregion
//SetCellValue
#region
/// <summary>
///对打开的Excel模版列进行单个设置数据值
/// </summary>
/// <param name="CellsValue">要设置的值</param>
/// <param name="RowIndex">要写入的行</param>
/// <param name="ColumnIndex">要写入的列</param>
public void SetCellValue(string CellsValue,int RowIndex,int ColumnIndex)
{
try
{
objectSheet.get_Range(objectSheet.Cells[RowIndex, ColumnIndex], objectSheet.Cells[RowIndex, ColumnIndex]).NumberFormatLocal = "@";
objectexcel.Cells[RowIndex,ColumnIndex] = CellsValue;
}
catch(Exception s)
{
WriteFileLog(s.Message);
}
}
#endregion
//GetCellValue
#region
/// <summary>
///对打开的Excel进行读取
/// </summary>
/// <param name="RowIndex">要读取的行</param>
/// <param name="ColumnIndex">要读取的列</param>
public String GetCellValue(int RowIndex, int ColumnIndex)
{
String CellsValue = String.Empty;
try
{
CellsValue = objectSheet.get_Range(objectexcel.Cells[RowIndex, ColumnIndex], objectexcel.Cells[RowIndex, ColumnIndex]).Value==null?String.Empty:objectSheet.get_Range(objectexcel.Cells[RowIndex, ColumnIndex], objectexcel.Cells[RowIndex, ColumnIndex]).Value.ToString();
}
catch (Exception s)
{
WriteFileLog("得到值错误:" + s.Message + ":cellvalues:" + CellsValue);
}
return CellsValue;
}
#endregion
虽然没看懂,但是先记起来.