-
Notifications
You must be signed in to change notification settings - Fork 306
ToText
Mats Alm edited this page Jul 26, 2020
·
16 revisions
This method exports a range in a worksheet to a string. You can configure the format of this content by using the ExcelOutputTextFormat class as input parameter. This method generates the same output as the SaveToText method, which sends the output to a file instead of a string.
Lets create a worksheet and add some values to the cells:
using(var package = new ExcelPackage())
{
var sheet = package.Workbook.Worksheets.Add("test");
sheet.Cells["A1"].Value = 1;
sheet.Cells["B1"].Value = 2;
sheet.Cells["A2"].Value = 3;
sheet.Cells["B2"].Value = 4;
}...and then call the ToText method:
var content = sheet.Cells["A1:B2"].ToText();The value of the string content will be "1,2\r\n3,4";
An instance of this class can be sent in as a parameter to the ToText method.
var format = new ExcelOutputTextFormat{
TextQualifier = '\''
};
var content = sheet.Cells["A1:B2"].ToText(format);The ExcelOutputTextFormat has the following properties:
- Header - A text written at the start of the content
- Footer - A text written at the end of the content
- FirstRowIsHeader (bool) - First row of the range contains the headers. All header cells will be treated as strings.
EPPlus Software AB - https://epplussoftware.com
- What is new in EPPlus 5+
- Breaking Changes in EPPlus 5
- Breaking Changes in EPPlus 6
- Breaking Changes in EPPlus 7
- Breaking Changes in EPPlus 8
- Addressing a worksheet
- Dimension/Used range
- Copying ranges/sheets
- Insert/Delete
- Filling ranges
- Sorting ranges
- Taking and skipping columns/rows
- Data validation
- Comments
- Freeze and Split Panes
- Header and Footer
- Hyperlinks
- Autofit columns
- Grouping and Ungrouping Rows and Columns
- Formatting and styling
- The ExcelRange.Text property
- Conditional formatting
- Using Themes
- Working with custom named table- or slicer- styles
-
Formula Calculation
- Security considerations
- Circular references
- Referencing tables in formulas
- Supported Functions
- Dynamic array formulas
- Legacy array formulas
- Lambda functions
- Regression analysis functions
- Custom functions for calculations
- Function prefixes
- Precision as Displayed
- Cancelling a calculation
- Trim reference operator
- Working with filters
- Working with slicers
- Working with External Workbooks