/// <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); } }
/// <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)); } }
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); } }
/// <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)); } }