Esempio n. 1
0
        public void SetRow(string columnName, int row, string value)
        {
            if (!ColName2Index.ContainsKey(columnName))
            {
                throw new Exception(string.Format("No Column: {0} of File: {1}", columnName, Path));
            }
            var theRow = Worksheet.GetRow(row);

            if (theRow == null)
            {
                theRow = Worksheet.CreateRow(row);
            }
            var cell = theRow.GetCell(ColName2Index[columnName]);

            if (cell == null)
            {
                cell = theRow.CreateCell(ColName2Index[columnName]);
            }

            if (value.Length > (1 << 14)) // if too long
            {
                value = value.Substring(0, 1 << 14);
            }
            cell.SetCellValue(value);
        }
Esempio n. 2
0
 /// <summary>
 /// 是否存在列名
 /// </summary>
 /// <param name="columnName"></param>
 /// <returns></returns>
 public bool HasColumn(string columnName)
 {
     return(ColName2Index.ContainsKey(columnName));
 }