-
Notifications
You must be signed in to change notification settings - Fork 807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formatting needs manual action to activate #707
Comments
I can't run your code sample. |
It was included more to show the process - adding worksheets through data sets as opposed to manually, and adding the formatting after the add. If there's no process to force the sheet to recognize the formatting changes, the code is rather moot. |
If you can't give me code that I can run to reproduce the issue, then there's nothing I can do about it. |
This works perfectly on my machine. using ClosedXML.Excel;
using System;
using System.Data;
using System.Linq;
public class Program
{
public static void Main()
{
using (var wb = new XLWorkbook())
{
var dataSet = GetDataSet();
// Add all DataTables in the DataSet as a worksheets
wb.Worksheets.Add(dataSet);
var ws = wb.Worksheets.First();
ws.Column(4).Style.DateFormat.Format = "d MMMM yyyy";
wb.SaveAs("outputfile.xlsx");
}
}
private static DataSet GetDataSet()
{
var ds = new DataSet();
ds.Tables.Add(GetTable("Patients"));
ds.Tables.Add(GetTable("Employees"));
ds.Tables.Add(GetTable("Information"));
return ds;
}
private static DataTable GetTable(String tableName)
{
DataTable table = new DataTable();
table.TableName = tableName;
table.Columns.Add("Dosage", typeof(int));
table.Columns.Add("Drug", typeof(string));
table.Columns.Add("Patient", typeof(string));
table.Columns.Add("Date", typeof(DateTime));
table.Rows.Add(25, "Indocin", "David", new DateTime(2000, 1, 1));
table.Rows.Add(50, "Enebrel", "Sam", new DateTime(2000, 1, 2));
table.Rows.Add(10, "Hydralazine", "Christoff", new DateTime(2000, 1, 3));
table.Rows.Add(21, "Combivent", "Janet", new DateTime(2000, 1, 4));
table.Rows.Add(100, "Dilantin", "Melanie", new DateTime(2000, 1, 5));
return table;
}
} |
Read and complete the full issue template
Do you want to request a feature or report a bug?
Version of ClosedXML
e.g. 0.87.1
What is the expected behavior or new feature?
Formatting set in ClosedXML does not correctly format data in the final document unless one uses text to columns or some other action on the data
Did this work in previous versions of our tool? Which versions?
Unknown
Reproducibility
Sample code for generating sheet from data table
The document has the formatting - you can check the columns in format data and it's there.
This is the same behavior as adding formatting to existing data in a sheet in Excel, so there's a chance there's no fix, save for the manual "tapping" I've been able to do. But a command to apply the formatting would be of use if it's not there.
The text was updated successfully, but these errors were encountered: