This project has moved. For the latest updates, please go here.
1

Resolved

Exporting resx with value true/false

description

When I export an resx with the value "false"/"true" it will be replaced by Excel "FALSE"/"TRUE" and I need manually to change that to a string "'False". Is is possible to add type for the cell so that all strings that is exported is always as "Text" and not "General" when open in Excel?

comments

Tasteful wrote Jun 17, 2016 at 8:25 AM

Updated the XlsxConverter.cs with the following and all strings is now exported as Text.
        private void AddData(ResourceDataGroupBase dataGroup, IXLWorksheet worksheet, int rowIndex, IEnumerable<CultureInfo> cultures)
        {
            worksheet.Cell(rowIndex, 1).Value = dataGroup.FileGroup.ID;
            worksheet.Cell(rowIndex, 2).Value = dataGroup.Name;

            int c = 3;
            foreach (var culture in cultures)
            {
                var cell = worksheet.Cell(rowIndex, c++);
                if (dataGroup.ResxData.ContainsKey(culture))
                {
                    cell.Value = dataGroup.ResxData[culture].Value;
                    if (ExportComments)
                    {
                        worksheet.Cell(rowIndex, c++).Value = dataGroup.ResxData[culture].Comment;
                    }
                }
                else
                {
                    cell.Value = "";
                    if (ExportComments)
                        worksheet.Cell(rowIndex, c++).Value = "";
                }
                cell.DataType = XLCellValues.Text; // need to set datatype after value is assigned, otherwise the datatype is parsed
            }
        }

wrote Jan 4 at 7:34 PM