예제 #1
0
        /// <summary>
        /// Write values to the spreadsheet.
        /// </summary>
        /// <param name="cellLocation">Row Column Value.</param>
        /// <param name="strValue">Value to write.</param>
        /// <param name="spreadSheet">Spreadsheet to write to. </param>
        /// <param name="workSheet">Worksheet to write to. </param>
        private static void WriteValues(string cellLocation, string strValue, SpreadsheetDocument spreadSheet, WorksheetPart workSheet)
        {
            WorksheetWriter workSheetWriter = new WorksheetWriter(spreadSheet, workSheet);

            int      intValue  = 0;
            DateTime dateValue = new DateTime();

            if (strValue.Contains("$"))
            {
                strValue = strValue.Replace("$", "");
                strValue = strValue.Replace(",", "");

                workSheetWriter.PasteValue(cellLocation, strValue, CellValues.Number);
            }
            else if (int.TryParse(strValue, out intValue))
            {
                workSheetWriter.PasteValue(cellLocation, strValue, CellValues.Number);
            }
            else if (string.IsNullOrEmpty(strValue))
            {
                workSheetWriter.PasteText(cellLocation, strValue);
            }
            //else if (DateTime.TryParse(strValue,out dateValue))
            //{
            //    workSheetWriter.PasteDate(cellLocation, dateValue);
            //}
            else
            {
                workSheetWriter.PasteText(cellLocation, strValue, SpreadsheetStyle.GetDefault(spreadSheet));
            }
        }
예제 #2
0
 public SpreadsheetStyle GetStyle()
 {
     return(SpreadsheetStyle.GetDefault(_doc));
 }