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


虽然没看懂,但是先记起来.

相关文章:

  • 2022-12-23
  • 2022-02-20
  • 2021-09-29
  • 2022-01-10
  • 2022-01-05
  • 2021-11-23
  • 2021-08-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-30
  • 2022-01-18
  • 2021-07-04
  • 2022-12-23
  • 2021-11-23
  • 2021-10-29
相关资源
相似解决方案