I'm giving a try to the EPPlus library and I'm stucked at this: I have to load a text in a single cell, but when this text contains a comma the code that I'm using split my text along multiple cells (along the right direction). Here is the code that I'm using to load the text:
using (ExcelPackage pck = new ExcelPackage())
{
//Create the worksheet
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("MySheet");
using (ExcelRange range = ws.Cells[1, 1])
{
range.LoadFromText("this works");
}
using (ExcelRange range = ws.Cells[1, 2])
{
range.LoadFromText("this, splits my , text in 3 parts");
}
}
I don't find a way to operate on a single cell or to instruct the LoadFromText method to not split my text.
EPPlus is a . NET Framework/. NET Core library for managing Office Open XML spreadsheets, distributed via Nuget . Version 5 supports . NET Framework from version 3.5 and .
You could wrap it in double quotes by specifying the TextQualifier
using (ExcelRange range = ws.Cells[1, 1])
{
var format = new OfficeOpenXml.ExcelTextFormat();
format.Delimiter = ',';
format.TextQualifier = '"';
format.DataTypes = new[] { eDataTypes.String };
range.LoadFromText("this, should, work, also, now", format);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With