Skip to content

Commit

Permalink
Merge pull request #126 from KorzhCom/dev
Browse files Browse the repository at this point in the history
Version 1.4.4
  • Loading branch information
melnalex authored Apr 20, 2022
2 parents 2f55a8c + 634c397 commit 85fbdd8
Show file tree
Hide file tree
Showing 388 changed files with 7,209 additions and 4,199 deletions.
82 changes: 41 additions & 41 deletions EasyData.Samples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,76 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.RazorPages.Net5", "samples\EasyDataBasicDemo.RazorPages.Net5\EasyDataBasicDemo.RazorPages.Net5.csproj", "{01AB0F07-3135-4206-9B7D-55E2DCFCEF45}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.RazorPages.NetCore31", "samples\EasyDataBasicDemo.RazorPages.NetCore31\EasyDataBasicDemo.RazorPages.NetCore31.csproj", "{A7B1EF24-2DDF-4512-AF72-34102913BF78}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.MVC.Net5", "samples\EasyDataBasicDemo.MVC.Net5\EasyDataBasicDemo.MVC.Net5.csproj", "{C26F86D2-E2E4-45D7-BFB2-CA99CABD134B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.RazorPages.Net6", "samples\EasyDataBasicDemo.RazorPages.Net6\EasyDataBasicDemo.RazorPages.Net6.csproj", "{409FEE7C-2FDA-4122-974F-1306063E8BA3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.MVC.Net6", "samples\EasyDataBasicDemo.MVC.Net6\EasyDataBasicDemo.MVC.Net6.csproj", "{372941BD-ED35-4AA2-B5CC-946527F66440}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.BlazorAppServer.Net5", "samples\EasyDataBasicDemo.BlazorAppServer.Net5\EasyDataBasicDemo.BlazorAppServer.Net5.csproj", "{F75567B4-C067-46E3-8F2E-5E79CB95DF61}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.Angular.Net6", "samples\EasyDataBasicDemo.Angular.Net6\EasyDataBasicDemo.Angular.Net6.csproj", "{4BBC1DDE-416B-4370-9345-0A0FAA53ED63}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EasyDataBasicDemo.BlazorWebAsm.Net5", "EasyDataBasicDemo.BlazorWebAsm.Net5", "{D156B42E-1DC2-4B4E-B68D-CF0F60D64F0B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.React.Net6", "samples\EasyDataBasicDemo.React.Net6\EasyDataBasicDemo.React.Net6.csproj", "{A1FFADD3-A719-4989-AF96-76CF057595F2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.BlazorWebAsm.Net5.Server", "samples\EasyDataBasicDemo.BlazorWebAsm.Net5\Server\EasyDataBasicDemo.BlazorWebAsm.Net5.Server.csproj", "{2B5D44F0-A9C9-4840-833C-FE65DDABC1A3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.BlazorAppServer.Net6", "samples\EasyDataBasicDemo.BlazorAppServer.Net6\EasyDataBasicDemo.BlazorAppServer.Net6.csproj", "{7D40E51C-607D-4017-A11B-901D3AA62DC1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.BlazorWebAsm.Net5.Client", "samples\EasyDataBasicDemo.BlazorWebAsm.Net5\Client\EasyDataBasicDemo.BlazorWebAsm.Net5.Client.csproj", "{47705E5D-F94B-4143-9457-4E67AC30FCA4}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyDataBasicDemo.BlazorWebAsm.Net6.Server", "samples\EasyDataBasicDemo.BlazorWebAsm.Net6\Server\EasyDataBasicDemo.BlazorWebAsm.Net6.Server.csproj", "{E5D61E8C-0F94-4AA6-BEC2-90AF75F79BC7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.BlazorWebAsm.Net5.Shared", "samples\EasyDataBasicDemo.BlazorWebAsm.Net5\Shared\EasyDataBasicDemo.BlazorWebAsm.Net5.Shared.csproj", "{6D213867-AC44-4789-8B30-C6C551ED30FA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyDataBasicDemo.BlazorWebAsm.Net6.Client", "samples\EasyDataBasicDemo.BlazorWebAsm.Net6\Client\EasyDataBasicDemo.BlazorWebAsm.Net6.Client.csproj", "{B057469E-32A2-4CC8-99C9-AA8E9439A352}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.Angular.Net5", "samples\EasyDataBasicDemo.Angular.Net5\EasyDataBasicDemo.Angular.Net5.csproj", "{014FF716-CA4A-48A6-90E8-6EC1CF664E8F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyDataBasicDemo.BlazorWebAsm.Net6.Shared", "samples\EasyDataBasicDemo.BlazorWebAsm.Net6\Shared\EasyDataBasicDemo.BlazorWebAsm.Net6.Shared.csproj", "{8E8FF59C-05B1-4902-9894-6E09C7C6DBE6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyDataBasicDemo.RazorPages.Net6", "samples\EasyDataBasicDemo.RazorPages.Net6\EasyDataBasicDemo.RazorPages.Net6.csproj", "{409FEE7C-2FDA-4122-974F-1306063E8BA3}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EasyDataBasicDemo.BlazorWebAsm.Net6", "EasyDataBasicDemo.BlazorWebAsm.Net6", "{B86364F5-A2C3-4578-AE5A-41B61D831E7D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{01AB0F07-3135-4206-9B7D-55E2DCFCEF45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01AB0F07-3135-4206-9B7D-55E2DCFCEF45}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01AB0F07-3135-4206-9B7D-55E2DCFCEF45}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01AB0F07-3135-4206-9B7D-55E2DCFCEF45}.Release|Any CPU.Build.0 = Release|Any CPU
{A7B1EF24-2DDF-4512-AF72-34102913BF78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A7B1EF24-2DDF-4512-AF72-34102913BF78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A7B1EF24-2DDF-4512-AF72-34102913BF78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A7B1EF24-2DDF-4512-AF72-34102913BF78}.Release|Any CPU.Build.0 = Release|Any CPU
{C26F86D2-E2E4-45D7-BFB2-CA99CABD134B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C26F86D2-E2E4-45D7-BFB2-CA99CABD134B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C26F86D2-E2E4-45D7-BFB2-CA99CABD134B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C26F86D2-E2E4-45D7-BFB2-CA99CABD134B}.Release|Any CPU.Build.0 = Release|Any CPU
{F75567B4-C067-46E3-8F2E-5E79CB95DF61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F75567B4-C067-46E3-8F2E-5E79CB95DF61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F75567B4-C067-46E3-8F2E-5E79CB95DF61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F75567B4-C067-46E3-8F2E-5E79CB95DF61}.Release|Any CPU.Build.0 = Release|Any CPU
{2B5D44F0-A9C9-4840-833C-FE65DDABC1A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2B5D44F0-A9C9-4840-833C-FE65DDABC1A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B5D44F0-A9C9-4840-833C-FE65DDABC1A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B5D44F0-A9C9-4840-833C-FE65DDABC1A3}.Release|Any CPU.Build.0 = Release|Any CPU
{47705E5D-F94B-4143-9457-4E67AC30FCA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47705E5D-F94B-4143-9457-4E67AC30FCA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47705E5D-F94B-4143-9457-4E67AC30FCA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47705E5D-F94B-4143-9457-4E67AC30FCA4}.Release|Any CPU.Build.0 = Release|Any CPU
{6D213867-AC44-4789-8B30-C6C551ED30FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D213867-AC44-4789-8B30-C6C551ED30FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D213867-AC44-4789-8B30-C6C551ED30FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D213867-AC44-4789-8B30-C6C551ED30FA}.Release|Any CPU.Build.0 = Release|Any CPU
{014FF716-CA4A-48A6-90E8-6EC1CF664E8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{014FF716-CA4A-48A6-90E8-6EC1CF664E8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{014FF716-CA4A-48A6-90E8-6EC1CF664E8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{014FF716-CA4A-48A6-90E8-6EC1CF664E8F}.Release|Any CPU.Build.0 = Release|Any CPU
{409FEE7C-2FDA-4122-974F-1306063E8BA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{409FEE7C-2FDA-4122-974F-1306063E8BA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{409FEE7C-2FDA-4122-974F-1306063E8BA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{409FEE7C-2FDA-4122-974F-1306063E8BA3}.Release|Any CPU.Build.0 = Release|Any CPU
{372941BD-ED35-4AA2-B5CC-946527F66440}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{372941BD-ED35-4AA2-B5CC-946527F66440}.Debug|Any CPU.Build.0 = Debug|Any CPU
{372941BD-ED35-4AA2-B5CC-946527F66440}.Release|Any CPU.ActiveCfg = Release|Any CPU
{372941BD-ED35-4AA2-B5CC-946527F66440}.Release|Any CPU.Build.0 = Release|Any CPU
{4BBC1DDE-416B-4370-9345-0A0FAA53ED63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4BBC1DDE-416B-4370-9345-0A0FAA53ED63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4BBC1DDE-416B-4370-9345-0A0FAA53ED63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4BBC1DDE-416B-4370-9345-0A0FAA53ED63}.Release|Any CPU.Build.0 = Release|Any CPU
{A1FFADD3-A719-4989-AF96-76CF057595F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1FFADD3-A719-4989-AF96-76CF057595F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1FFADD3-A719-4989-AF96-76CF057595F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1FFADD3-A719-4989-AF96-76CF057595F2}.Release|Any CPU.Build.0 = Release|Any CPU
{7D40E51C-607D-4017-A11B-901D3AA62DC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D40E51C-607D-4017-A11B-901D3AA62DC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D40E51C-607D-4017-A11B-901D3AA62DC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D40E51C-607D-4017-A11B-901D3AA62DC1}.Release|Any CPU.Build.0 = Release|Any CPU
{E5D61E8C-0F94-4AA6-BEC2-90AF75F79BC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5D61E8C-0F94-4AA6-BEC2-90AF75F79BC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5D61E8C-0F94-4AA6-BEC2-90AF75F79BC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E5D61E8C-0F94-4AA6-BEC2-90AF75F79BC7}.Release|Any CPU.Build.0 = Release|Any CPU
{B057469E-32A2-4CC8-99C9-AA8E9439A352}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B057469E-32A2-4CC8-99C9-AA8E9439A352}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B057469E-32A2-4CC8-99C9-AA8E9439A352}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B057469E-32A2-4CC8-99C9-AA8E9439A352}.Release|Any CPU.Build.0 = Release|Any CPU
{8E8FF59C-05B1-4902-9894-6E09C7C6DBE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E8FF59C-05B1-4902-9894-6E09C7C6DBE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E8FF59C-05B1-4902-9894-6E09C7C6DBE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E8FF59C-05B1-4902-9894-6E09C7C6DBE6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2B5D44F0-A9C9-4840-833C-FE65DDABC1A3} = {D156B42E-1DC2-4B4E-B68D-CF0F60D64F0B}
{47705E5D-F94B-4143-9457-4E67AC30FCA4} = {D156B42E-1DC2-4B4E-B68D-CF0F60D64F0B}
{6D213867-AC44-4789-8B30-C6C551ED30FA} = {D156B42E-1DC2-4B4E-B68D-CF0F60D64F0B}
{E5D61E8C-0F94-4AA6-BEC2-90AF75F79BC7} = {B86364F5-A2C3-4578-AE5A-41B61D831E7D}
{B057469E-32A2-4CC8-99C9-AA8E9439A352} = {B86364F5-A2C3-4578-AE5A-41B61D831E7D}
{8E8FF59C-05B1-4902-9894-6E09C7C6DBE6} = {B86364F5-A2C3-4578-AE5A-41B61D831E7D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {15562A42-D965-4A8E-B708-CF2E36429B26}
Expand Down
3 changes: 2 additions & 1 deletion easydata.js/packs/core/src/meta/meta_entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ export class MetaEntityAttr {
this.dataAttr = dto.dattr;
this.lookupDataAttr = dto.ldattr;

this.defaultValue = dto.defVal;
const isDataType = utils.getDateDataTypes().indexOf(this.dataType);
this.defaultValue = dto.defVal && isDataType ? new Date(dto.defVal) : dto.defVal;

this.isNullable = utils.getIfDefined(dto.nul, this.isNullable);
this.isEditable = utils.getIfDefined(dto.ied, this.isEditable);
Expand Down
6 changes: 3 additions & 3 deletions easydata.js/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.4.3",
"baseVersion": "1.4.3",
"assetVersion": "01_04_03",
"version": "1.4.4",
"baseVersion": "1.4.4",
"assetVersion": "01_04_04",
"tag": "latest"
}
33 changes: 26 additions & 7 deletions easydata.net/src/EasyData.Core/Common/DataFormatUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,45 @@ public static string GetFormattedValue(object val, DataType dataType, CultureInf
return "";
}

if (val is DateTime) {
DateTime dt = (DateTime)val;

if (val is DateTime dt) {
if (!string.IsNullOrEmpty(displayFormat)) {
return string.Format(culture, displayFormat, val);
}

var format = BuildShortDateTimeFormat(culture, dataType);
return dt.ToString(format, CultureInfo.InvariantCulture);
}
else if (val is DateTimeOffset) {
DateTimeOffset dt = (DateTimeOffset)val;

else if (val is DateTimeOffset dto) {
if (!string.IsNullOrEmpty(displayFormat)) {
return string.Format(culture, displayFormat, val);
}

var format = BuildShortDateTimeFormat(culture, dataType);
return dt.ToString(format, CultureInfo.InvariantCulture);
return dto.ToString(format, CultureInfo.InvariantCulture);
}
else if (val is TimeSpan ts) {
if (!string.IsNullOrEmpty(displayFormat)) {
return string.Format(culture, displayFormat, val);
}

return ts.ToString(culture.DateTimeFormat.ShortTimePattern, CultureInfo.InvariantCulture);
}
#if NET6_0_OR_GREATER
else if (val is DateOnly @do) {
if (!string.IsNullOrEmpty(displayFormat)) {
return string.Format(culture, displayFormat, val);
}

return @do.ToString(culture.DateTimeFormat.ShortDatePattern, CultureInfo.InvariantCulture);
}
else if (val is TimeOnly to) {
if (!string.IsNullOrEmpty(displayFormat)) {
return string.Format(culture, displayFormat, val);
}

return to.ToString(culture.DateTimeFormat.ShortTimePattern, CultureInfo.InvariantCulture);
}
#endif
else if (val is float || val is double || val is int || val is decimal) {
if (!string.IsNullOrEmpty(displayFormat))
return string.Format(culture, displayFormat, val);
Expand Down
2 changes: 1 addition & 1 deletion easydata.net/src/EasyData.Core/EasyData.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,7 @@ public Func<EasyDataRow, BeforeRowAddedCallback, CancellationToken, Task> Before
public bool PreserveFormatting { get; set; } = true;

public AggregationSettings Aggregation { get; set; } = new AggregationSettings();

public int RowLimit { get; set; } = 0;
}
}
2 changes: 2 additions & 0 deletions easydata.net/src/EasyData.Core/Export/IDataExportSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,7 @@ public interface IDataExportSettings
bool PreserveFormatting { get; set; }

AggregationSettings Aggregation { get; set; }

int RowLimit { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,20 @@ protected virtual MetaEntity ProcessEntityType(IEntityType entityType)
{
var entity = Model.CreateEntity();
entity.Id = GetEntityId(entityType);

entity.Name = DataUtils.PrettifyName(Utils.GetEntityName(entityType));
entity.NamePlural = DataUtils.MakePlural(entity.Name);
if (entityType.ClrType.GetCustomAttribute(typeof(DisplayAttribute)) is DisplayAttribute displayAttr) {
entity.Name = displayAttr.Name;
entity.Description = displayAttr.Description;
}

var primaryKey = entityType.FindPrimaryKey();
entity.IsEditable = primaryKey != null;

entity.ClrType = entityType.ClrType;

entity.NamePlural = DataUtils.MakePlural(entity.Name);

var annotation = (MetaEntityAttribute)entityType.ClrType.GetCustomAttribute(typeof(MetaEntityAttribute));
if (annotation != null) {
if (!annotation.Enabled)
Expand Down Expand Up @@ -439,6 +445,7 @@ protected virtual MetaEntityAttr CreateEntityAttribute(MetaEntity entity, IEntit
if (propInfo != null) {
if (propInfo.GetCustomAttribute(typeof(DisplayAttribute)) is DisplayAttribute displayAttr) {
entityAttr.Caption = displayAttr.Name;
entityAttr.Description = displayAttr.Description;
}
else {
entityAttr.Caption = DataUtils.PrettifyName(entityAttr.Caption);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,15 @@ Task WriteRowAsync(EasyDataRow row, bool isExtraRow = false,

// setting the cell's format
cell.DataType = excelDataType;
if (excelDataType == XLDataType.DateTime) {
var format = Utils.GetExcelDateFormat(column.DataType, mappedSettings, dfmt);
if (!string.IsNullOrEmpty(format))
cell.Style.DateFormat.Format = format;
}
else if (excelDataType == XLDataType.Number) {
var format = Utils.GetExcelNumberFormat(mappedSettings, dfmt);
if (!string.IsNullOrEmpty(format))
cell.Style.NumberFormat.Format = format;
var cellFormat = GetCellFormat(excelDataType, column.DataType, mappedSettings, dfmt);
if (!string.IsNullOrEmpty(cellFormat)) {
if (excelDataType == XLDataType.Number) {
cell.Style.NumberFormat.Format = cellFormat;
}
else {
cell.Style.DateFormat.Format = cellFormat;
}
}

cell.Style.Alignment.Horizontal = MapAlignment(column.Style.Alignment);

if (isExtraRow)
Expand All @@ -198,15 +196,21 @@ Task WriteRowAsync(EasyDataRow row, bool isExtraRow = false,
WriteRowFunc WriteExtraRowAsync = (extraRow, extraData, cancellationToken)
=> WriteRowAsync(extraRow, true, extraData, cancellationToken);

var currentRowNum = 0;
foreach (var row in data.Rows) {
var add = settings?.RowFilter?.Invoke(row);
if (add.HasValue && !add.Value)
continue;

if (settings.RowLimit > 0 && currentRowNum >= settings.RowLimit)
continue;

if (mappedSettings.BeforeRowInsert != null)
await mappedSettings.BeforeRowInsert(row, WriteExtraRowAsync, ct);

await WriteRowAsync(row, cancellationToken: ct);

currentRowNum++;
}

if (mappedSettings.BeforeRowInsert != null)
Expand Down Expand Up @@ -362,6 +366,20 @@ private List<int> GetIgnoredColumns(IEasyDataResultSet data, IDataExportSettings

return result;
}

private static string GetCellFormat(XLDataType xlDataType, DataType dataType, ExcelDataExportSettings settings, string format)
{
switch (xlDataType) {
case XLDataType.DateTime:
return Utils.GetExcelDateFormat(dataType, settings, format);
case XLDataType.Number:
return Utils.GetExcelNumberFormat(settings, format);
case XLDataType.TimeSpan:
return Utils.GetExcelTimeFormat(settings, format);
default:
return null;
}
}
}

}
10 changes: 10 additions & 0 deletions easydata.net/src/EasyData.Exporters.ClosedXML/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ public static string GetExcelNumberFormat(IDataExportSettings settings, string d
return dataFormat;
}

public static string GetExcelTimeFormat(IDataExportSettings setting, string dataFormat)
{
if (_formatRegex.IsMatch(dataFormat)) {
var format = _formatRegex.Match(dataFormat).Groups[1].Value;
return format;
}

return dataFormat;
}

public static string GetExcelDateFormat(DataType dataType, IDataExportSettings settings, string dataFormat)
{
if (!string.IsNullOrEmpty(dataFormat)) {
Expand Down
Loading

0 comments on commit 85fbdd8

Please sign in to comment.