32 AddFormattedText(worksheet, formattedText, columnNumber, rowNumber);
48 AddFormattedText(worksheet, formattedText, columnNumber, rowNumber, style);
64 Cell.ResolveCellCoordinate(address, out column, out row);
65 AddFormattedText(worksheet, formattedText, column, row);
82 Cell.ResolveCellCoordinate(address, out column, out row);
83 AddFormattedText(worksheet, formattedText, column, row, style);
96 AddFormattedText(worksheet, formattedText);
110 AddFormattedText(worksheet, formattedText, style);
124 public static void AddFormattedTextCellRange(
this Worksheet worksheet, IReadOnlyList<FormattedText> values,
string startAddress,
string endAddress, Style style =
null)
126 AddFormattedTextRange(worksheet, values, (Address)startAddress, (Address)endAddress, style);
140 public static void AddFormattedTextCellRange(
this Worksheet worksheet, IReadOnlyList<FormattedText> values, Address startAddress, Address endAddress, Style style =
null)
142 AddFormattedTextRange(worksheet, values, startAddress, endAddress, style);
156 public static void AddFormattedTextCellRange(
this Worksheet worksheet, IReadOnlyList<FormattedText> values,
string cellRange, Style style =
null)
158 Range range =
new Range(cellRange);
159 AddFormattedTextRange(worksheet, values, range.StartAddress, range.EndAddress, style);
172 private static void AddFormattedText(Worksheet worksheet,
FormattedText formattedText,
int columnNumber,
int rowNumber, Style cellStyle =
null)
174 if (formattedText ==
null)
176 throw new WorksheetException(
"A formatted text to add cannot be null");
180 if (cellStyle ==
null)
182 worksheet.AddCell(formattedText, columnNumber, rowNumber, FormattedText.LineBreakStyle);
186 Style mergedStyle = cellStyle.Append(FormattedText.LineBreakStyle);
187 worksheet.AddCell(formattedText, columnNumber, rowNumber, mergedStyle);
192 worksheet.AddCell(formattedText, columnNumber, rowNumber, cellStyle);
203 private static void AddFormattedText(Worksheet worksheet, FormattedText formattedText, Style cellStyle =
null)
205 if (formattedText ==
null)
207 throw new WorksheetException(
"A formatted text to add cannot be null");
209 if (formattedText.WrapText)
211 if (cellStyle ==
null)
213 worksheet.AddNextCell(formattedText, FormattedText.LineBreakStyle);
217 Style mergedStyle = cellStyle.Append(FormattedText.LineBreakStyle);
218 worksheet.AddNextCell(formattedText, mergedStyle);
223 worksheet.AddNextCell(formattedText, cellStyle);
236 private static void AddFormattedTextRange(Worksheet worksheet, IReadOnlyList<FormattedText> formattedTexts, Address startAddress, Address endAddress, Style cellStyle =
null)
238 if (formattedTexts ==
null || formattedTexts.Count == 0)
240 throw new WorksheetException(
"A range of formatted texts to add cannot be null or empty");
242 List<Cell> cells =
new List<Cell>(formattedTexts.Count);
243 foreach (FormattedText text
in formattedTexts)
245 if (text ==
null ||
string.IsNullOrEmpty(text.PlainText))
247 Cell emptyCell =
new Cell(
null, Cell.CellType.Empty);
248 if (cellStyle !=
null)
250 emptyCell.SetStyle(cellStyle);
252 cells.Add(emptyCell);
255 Cell cell =
new Cell(text, Cell.CellType.String);
256 if (text.WrapText && cellStyle !=
null)
258 Style merged = cellStyle.Append(FormattedText.LineBreakStyle);
259 cell.SetStyle(merged);
261 else if (text.WrapText && cellStyle ==
null)
263 cell.SetStyle(FormattedText.LineBreakStyle);
265 else if (!text.WrapText && cellStyle !=
null)
267 cell.SetStyle(cellStyle);
271 if (cellStyle !=
null)
273 worksheet.AddCellRange(cells, startAddress, endAddress, cellStyle);
277 worksheet.AddCellRange(cells, startAddress, endAddress);
Writer extension methods for the Worksheet class.
static void AddFormattedTextCell(this Worksheet worksheet, FormattedText formattedText, int columnNumber, int rowNumber, Style style)
Adds a formatted text to the specified cell with a style. If the WrapText property of the formatted t...
static void AddFormattedTextCellRange(this Worksheet worksheet, IReadOnlyList< FormattedText > values, string cellRange, Style style=null)
Adds a list of formatted texts to a defined cell range with a style applied to all cells....
static void AddFormattedTextCell(this Worksheet worksheet, FormattedText formattedText, string address, Style style)
Adds a formatted text to the specified cell address with a style. If the WrapText property of the for...
static void AddFormattedTextCellRange(this Worksheet worksheet, IReadOnlyList< FormattedText > values, string startAddress, string endAddress, Style style=null)
Adds a list of formatted texts to a defined cell range. Values are distributed column-by-column from ...
static void AddFormattedTextCell(this Worksheet worksheet, FormattedText formattedText, string address)
Adds a formatted text to the specified cell address. If the WrapText property of the formatted text i...
static void AddFormattedTextCellRange(this Worksheet worksheet, IReadOnlyList< FormattedText > values, Address startAddress, Address endAddress, Style style=null)
Adds a list of formatted texts to a defined cell range with a style applied to all cells....
static void AddFormattedTextCell(this Worksheet worksheet, FormattedText formattedText, int columnNumber, int rowNumber)
Adds a formatted text to the specified cell. If the WrapText property of the formatted text is set to...
static void AddNextFormattedTextCell(this Worksheet worksheet, FormattedText formattedText, Style style)
Adds a formatted text to the next cell position with a style. The direction of the next cell depends ...
static void AddNextFormattedTextCell(this Worksheet worksheet, FormattedText formattedText)
Adds a formatted text to the next cell position. The direction of the next cell depends on the curren...