Example #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;

            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
            {
                workSheetWriter.PasteText(cellLocation, strValue);
            }
        }
Example #2
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));
            }
        }
Example #3
0
        public void WriteCell(string column, int row, string value, SpreadsheetStyle style = null)
        {
            var startCell = column + row;

            _writer.PasteValue(startCell, value, CellValues.String);

            if (style != null)
            {
                var endCell = column + row;
                _writer.SetStyle(style, startCell, endCell);
            }
        }
Example #4
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));
             }
        }
Example #5
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;
             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
             {
            workSheetWriter.PasteText(cellLocation, strValue);
             }
        }