From a7a169502efcb0db0c3f9add23514eb3994e88e4 Mon Sep 17 00:00:00 2001 From: Oleksandr Melnychenko Date: Fri, 24 Jun 2022 15:29:16 +0300 Subject: [PATCH 1/8] [fix] Excel autoformatting text to date workaround --- .../src/EasyData.Exporters.ClosedXML/Excel/ExcelDataExporter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easydata.net/src/EasyData.Exporters.ClosedXML/Excel/ExcelDataExporter.cs b/easydata.net/src/EasyData.Exporters.ClosedXML/Excel/ExcelDataExporter.cs index 0869bffa..a2fdd678 100644 --- a/easydata.net/src/EasyData.Exporters.ClosedXML/Excel/ExcelDataExporter.cs +++ b/easydata.net/src/EasyData.Exporters.ClosedXML/Excel/ExcelDataExporter.cs @@ -170,7 +170,7 @@ Task WriteRowAsync(EasyDataRow row, bool isExtraRow = false, } cell.DataType = excelDataType; - cell.Value = value; + cell.Value = excelDataType == XLDataType.Text ? "'" + value : value; // setting the cell's format var cellFormat = GetCellFormat(excelDataType, column.DataType, mappedSettings, dfmt); From 13c34ba526912b8258304f60a5f8fdece54b12bf Mon Sep 17 00:00:00 2001 From: Oleksandr Melnychenko Date: Tue, 28 Jun 2022 18:24:51 +0300 Subject: [PATCH 2/8] [fix] grid footer not cleared before rendering --- easydata.js/packs/ui/src/grid/easy_grid.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/easydata.js/packs/ui/src/grid/easy_grid.ts b/easydata.js/packs/ui/src/grid/easy_grid.ts index 7535f89f..d96f4b46 100644 --- a/easydata.js/packs/ui/src/grid/easy_grid.ts +++ b/easydata.js/packs/ui/src/grid/easy_grid.ts @@ -866,6 +866,8 @@ export class EasyGrid { if (this.rowsOnPagePromise) { this.rowsOnPagePromise.then(count => { + this.footerDiv.innerHTML = ''; + this.footerPaginateDiv = this.renderPageNavigator(); this.footerDiv.appendChild(this.footerPaginateDiv); const pageInfoBlock = this.renderPageInfoBlock(count); From e8e8da5f5ffb6b74496b1562a175a1f50eddae2a Mon Sep 17 00:00:00 2001 From: Sergiy Korzh Date: Wed, 29 Jun 2022 11:39:15 +0300 Subject: [PATCH 3/8] Add GetPageWidth function to PdfExporter --- .../Pdf/PdfDataExporter.cs | 99 +++++++++++++++---- 1 file changed, 82 insertions(+), 17 deletions(-) diff --git a/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs b/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs index f306cba6..ad8e42ca 100644 --- a/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs +++ b/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs @@ -87,30 +87,30 @@ public Task ExportAsync(IEasyDataResultSet data, Stream stream, CancellationToke /// Task. public async Task ExportAsync(IEasyDataResultSet data, Stream stream, IDataExportSettings settings, CancellationToken ct = default) { - var mappedSettings = MapSettings(settings); + var pdfSettings = MapSettings(settings); var document = new Document(); - document.Info.Title = mappedSettings.Title; - document.DefaultPageSetup.Orientation = mappedSettings.Orientation; - document.DefaultPageSetup.PageFormat = mappedSettings.PageFormat; + document.Info.Title = pdfSettings.Title; + document.DefaultPageSetup.Orientation = pdfSettings.Orientation; + document.DefaultPageSetup.PageFormat = pdfSettings.PageFormat; - ApplyStyles(document, mappedSettings); + ApplyStyles(document, pdfSettings); var section = document.AddSection(); if (settings.ShowDatasetInfo) { // TODO: render paragrap with info here - if (!string.IsNullOrWhiteSpace(mappedSettings.Title)) { + if (!string.IsNullOrWhiteSpace(pdfSettings.Title)) { var p = section.AddParagraph(); p.Format.Alignment = ParagraphAlignment.Center; p.Format.Font.Bold = true; - p.AddText(mappedSettings.Title); + p.AddText(pdfSettings.Title); } - if (!string.IsNullOrWhiteSpace(mappedSettings.Description)) { + if (!string.IsNullOrWhiteSpace(pdfSettings.Description)) { var p = section.AddParagraph(); p.Format.Alignment = ParagraphAlignment.Left; - p.AddText(mappedSettings.Description); + p.AddText(pdfSettings.Description); } } @@ -128,10 +128,11 @@ public async Task ExportAsync(IEasyDataResultSet data, Stream stream, IDataExpor // predefined formatters var predefinedFormatters = GetPredefinedFormatters(data.Cols, settings); - // filling columns - - //ignored columns + // getting ignored columns var ignoredCols = GetIgnoredColumns(data, settings); + + var pageWidth = GetPageWidth(pdfSettings); + // filling columns int colsCount = 0; for (int i = 0; i < data.Cols.Count; i++) { if (ignoredCols.Contains(i)) @@ -192,7 +193,7 @@ Task WriteRowAsync(EasyDataRow row, bool isExtra = false, value = string.Format(provider, dfmt, row[i]); } else { - value = Utils.GetFormattedValue(row[i], type, mappedSettings, dfmt); + value = Utils.GetFormattedValue(row[i], type, pdfSettings, dfmt); } if (!string.IsNullOrEmpty(value) && isExtra && !string.IsNullOrEmpty(gfct)) { @@ -218,8 +219,8 @@ Task WriteRowAsync(EasyDataRow row, bool isExtra = false, var currentRowNum = 0; foreach (var row in rows) { - if (mappedSettings.BeforeRowInsert != null) - await mappedSettings.BeforeRowInsert(row, WriteExtraRowAsync, ct); + if (pdfSettings.BeforeRowInsert != null) + await pdfSettings.BeforeRowInsert(row, WriteExtraRowAsync, ct); if (settings.RowLimit > 0 && currentRowNum >= settings.RowLimit) continue; @@ -229,8 +230,8 @@ Task WriteRowAsync(EasyDataRow row, bool isExtra = false, currentRowNum++; } - if (mappedSettings.BeforeRowInsert != null) { - await mappedSettings.BeforeRowInsert(null, WriteExtraRowAsync, ct); + if (pdfSettings.BeforeRowInsert != null) { + await pdfSettings.BeforeRowInsert(null, WriteExtraRowAsync, ct); } // rendering pdf @@ -246,6 +247,70 @@ Task WriteRowAsync(EasyDataRow row, bool isExtra = false, } } + private int GetPageWidth(PdfDataExportSettings pdfSettings) + { + if (pdfSettings.Orientation == Orientation.Landscape) { + switch (pdfSettings.PageFormat) { + case PageFormat.A0: + return 1189; + case PageFormat.A1: + return 841; + case PageFormat.A2: + return 594; + case PageFormat.A3: + return 420; + case PageFormat.A4: + return 297; + case PageFormat.A5: + return 210; + case PageFormat.A6: + return 148; + case PageFormat.B5: + return 250; + case PageFormat.Letter: + return 279; + case PageFormat.Legal: + return 356; + case PageFormat.Ledger: + return 432; + case PageFormat.P11x17: + return 279; + default: + return 297; + } + } + else { + switch (pdfSettings.PageFormat) { + case PageFormat.A0: + return 841; + case PageFormat.A1: + return 594; + case PageFormat.A2: + return 420; + case PageFormat.A3: + return 297; + case PageFormat.A4: + return 210; + case PageFormat.A5: + return 148; + case PageFormat.A6: + return 105; + case PageFormat.B5: + return 176; + case PageFormat.Letter: + return 216; + case PageFormat.Legal: + return 216; + case PageFormat.Ledger: + return 279; + case PageFormat.P11x17: + return 432; + default: + return 210; + } + } + } + private Dictionary GetPredefinedFormatters(IReadOnlyList cols, IDataExportSettings settings) { var result = new Dictionary(); From 6df52d4014cce899d28bd0e57867f8a13d6a72d5 Mon Sep 17 00:00:00 2001 From: Sergiy Korzh Date: Thu, 30 Jun 2022 00:01:11 +0300 Subject: [PATCH 4/8] [new] Margins property in PdfExportSettings --- .../Pdf/PdfDataExportSettings.cs | 4 ++++ .../src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExportSettings.cs b/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExportSettings.cs index 21521587..778d409b 100644 --- a/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExportSettings.cs +++ b/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExportSettings.cs @@ -40,5 +40,9 @@ public PdfDataExportSettings(CultureInfo culture) : base(culture) /// public PageFormat PageFormat { get; set; } = PageFormat.A4; + /// + /// Page margins (in milimiters) + /// + public (short Left, short Top, short Right, short Bottom) Margins { get; set; } = (25, 25, 25, 25); } } diff --git a/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs b/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs index ad8e42ca..c9911104 100644 --- a/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs +++ b/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs @@ -132,13 +132,18 @@ public async Task ExportAsync(IEasyDataResultSet data, Stream stream, IDataExpor var ignoredCols = GetIgnoredColumns(data, settings); var pageWidth = GetPageWidth(pdfSettings); + + var colCount = data.Cols.Count - ignoredCols.Count; + + var colWidth = (double)(pageWidth - pdfSettings.Margins.Left - pdfSettings.Margins.Right) / colCount; + // filling columns int colsCount = 0; for (int i = 0; i < data.Cols.Count; i++) { if (ignoredCols.Contains(i)) continue; - var column = table.AddColumn(Unit.FromCentimeter(3)); + var column = table.AddColumn(Unit.FromMillimeter(Math.Round(colWidth))); column.Format.Alignment = ParagraphAlignment.Center; colsCount++; } From bfb55e8b76ad21ac7d7a658872fba1302edf2cea Mon Sep 17 00:00:00 2001 From: Sergiy Korzh Date: Thu, 30 Jun 2022 00:12:35 +0300 Subject: [PATCH 5/8] [upd] Fit-to-page option in PdfDataExporter --- .../Pdf/PdfDataExportSettings.cs | 3 +-- .../src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExportSettings.cs b/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExportSettings.cs index 778d409b..e0301244 100644 --- a/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExportSettings.cs +++ b/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExportSettings.cs @@ -26,8 +26,7 @@ public PdfDataExportSettings() : base() /// Initializes a new instance of the class. /// public PdfDataExportSettings(CultureInfo culture) : base(culture) - { - + { } /// diff --git a/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs b/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs index c9911104..b3d7dd02 100644 --- a/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs +++ b/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs @@ -133,9 +133,10 @@ public async Task ExportAsync(IEasyDataResultSet data, Stream stream, IDataExpor var pageWidth = GetPageWidth(pdfSettings); + //calculating the width of one column var colCount = data.Cols.Count - ignoredCols.Count; - - var colWidth = (double)(pageWidth - pdfSettings.Margins.Left - pdfSettings.Margins.Right) / colCount; + double pageContentWidth = pageWidth - pdfSettings.Margins.Left - pdfSettings.Margins.Right; + var colWidth = pageContentWidth / colCount; // filling columns int colsCount = 0; @@ -143,7 +144,7 @@ public async Task ExportAsync(IEasyDataResultSet data, Stream stream, IDataExpor if (ignoredCols.Contains(i)) continue; - var column = table.AddColumn(Unit.FromMillimeter(Math.Round(colWidth))); + var column = table.AddColumn(Unit.FromMillimeter(colWidth)); column.Format.Alignment = ParagraphAlignment.Center; colsCount++; } From 785210b0ee6a49a19427854cd993815777e33dc6 Mon Sep 17 00:00:00 2001 From: Sergiy Korzh Date: Thu, 30 Jun 2022 00:13:43 +0300 Subject: [PATCH 6/8] Version 1.4.9-rc01 --- easydata.js/version.json | 8 ++++---- easydata.net/version.json | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/easydata.js/version.json b/easydata.js/version.json index 550d9926..0c948a7a 100644 --- a/easydata.js/version.json +++ b/easydata.js/version.json @@ -1,6 +1,6 @@ { - "version": "1.4.8", - "baseVersion": "1.4.8", - "assetVersion": "01_04_08", - "tag": "latest" + "version": "1.4.9-rc01", + "baseVersion": "1.4.9", + "assetVersion": "01_04_09", + "tag": "beta" } diff --git a/easydata.net/version.json b/easydata.net/version.json index b2170c1f..e013bc1d 100644 --- a/easydata.net/version.json +++ b/easydata.net/version.json @@ -1,5 +1,5 @@ { - "assemblyVersion": "1.4.8.1", - "packageVersion": "1.4.8", - "assetVersion": "01_04_08" + "assemblyVersion": "1.4.9.1", + "packageVersion": "1.4.9-rc01", + "assetVersion": "01_04_09" } From d4471bf7fc2ff2c16a83c082ef4ddb9306d6bd5c Mon Sep 17 00:00:00 2001 From: Sergiy Korzh Date: Sat, 2 Jul 2022 14:57:20 +0300 Subject: [PATCH 7/8] Fix page setup setting on PDF export. Version 1.4.9-rc02 --- .../Pdf/PdfDataExporter.cs | 95 +++++++------------ easydata.net/version.json | 4 +- 2 files changed, 36 insertions(+), 63 deletions(-) diff --git a/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs b/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs index b3d7dd02..9e590c6f 100644 --- a/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs +++ b/easydata.net/src/EasyData.Exporters.PdfSharp/Pdf/PdfDataExporter.cs @@ -94,9 +94,11 @@ public async Task ExportAsync(IEasyDataResultSet data, Stream stream, IDataExpor document.DefaultPageSetup.Orientation = pdfSettings.Orientation; document.DefaultPageSetup.PageFormat = pdfSettings.PageFormat; + ApplyStyles(document, pdfSettings); var section = document.AddSection(); + section.PageSetup.PageFormat = pdfSettings.PageFormat; if (settings.ShowDatasetInfo) { // TODO: render paragrap with info here @@ -131,7 +133,10 @@ public async Task ExportAsync(IEasyDataResultSet data, Stream stream, IDataExpor // getting ignored columns var ignoredCols = GetIgnoredColumns(data, settings); - var pageWidth = GetPageWidth(pdfSettings); + var pageSizes = GetPageSizes(pdfSettings.PageFormat); + var pageWidth = pdfSettings.Orientation == Orientation.Landscape + ? pageSizes.Height + : pageSizes.Width; //calculating the width of one column var colCount = data.Cols.Count - ignoredCols.Count; @@ -253,67 +258,35 @@ Task WriteRowAsync(EasyDataRow row, bool isExtra = false, } } - private int GetPageWidth(PdfDataExportSettings pdfSettings) + private (int Width, int Height) GetPageSizes(PageFormat pageFormat) { - if (pdfSettings.Orientation == Orientation.Landscape) { - switch (pdfSettings.PageFormat) { - case PageFormat.A0: - return 1189; - case PageFormat.A1: - return 841; - case PageFormat.A2: - return 594; - case PageFormat.A3: - return 420; - case PageFormat.A4: - return 297; - case PageFormat.A5: - return 210; - case PageFormat.A6: - return 148; - case PageFormat.B5: - return 250; - case PageFormat.Letter: - return 279; - case PageFormat.Legal: - return 356; - case PageFormat.Ledger: - return 432; - case PageFormat.P11x17: - return 279; - default: - return 297; - } - } - else { - switch (pdfSettings.PageFormat) { - case PageFormat.A0: - return 841; - case PageFormat.A1: - return 594; - case PageFormat.A2: - return 420; - case PageFormat.A3: - return 297; - case PageFormat.A4: - return 210; - case PageFormat.A5: - return 148; - case PageFormat.A6: - return 105; - case PageFormat.B5: - return 176; - case PageFormat.Letter: - return 216; - case PageFormat.Legal: - return 216; - case PageFormat.Ledger: - return 279; - case PageFormat.P11x17: - return 432; - default: - return 210; - } + switch (pageFormat) { + case PageFormat.A0: + return (841, 1189); + case PageFormat.A1: + return (594, 841); + case PageFormat.A2: + return (420, 594); + case PageFormat.A3: + return (297, 420); + case PageFormat.A4: + return (210, 297); + case PageFormat.A5: + return (148, 210); + case PageFormat.A6: + return (105, 148); + case PageFormat.B5: + return (176, 250); + case PageFormat.Letter: + return (216, 279); + case PageFormat.Legal: + return (216, 356); + case PageFormat.Ledger: + return (279, 432); + case PageFormat.P11x17: + return (432, 279); + default: + return (210, 297); //return A4 sizes by default } } diff --git a/easydata.net/version.json b/easydata.net/version.json index e013bc1d..72c9867a 100644 --- a/easydata.net/version.json +++ b/easydata.net/version.json @@ -1,5 +1,5 @@ { - "assemblyVersion": "1.4.9.1", - "packageVersion": "1.4.9-rc01", + "assemblyVersion": "1.4.9.2", + "packageVersion": "1.4.9-rc02", "assetVersion": "01_04_09" } From 42f98ac0af743199df079f7f79dc18837b557633 Mon Sep 17 00:00:00 2001 From: EasyQuery team lead Date: Mon, 4 Jul 2022 22:26:12 +0300 Subject: [PATCH 8/8] Version 1.4.9 --- easydata.js/version.json | 2 +- easydata.net/version.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/easydata.js/version.json b/easydata.js/version.json index 0c948a7a..af523855 100644 --- a/easydata.js/version.json +++ b/easydata.js/version.json @@ -1,5 +1,5 @@ { - "version": "1.4.9-rc01", + "version": "1.4.9", "baseVersion": "1.4.9", "assetVersion": "01_04_09", "tag": "beta" diff --git a/easydata.net/version.json b/easydata.net/version.json index 72c9867a..18e0fa8b 100644 --- a/easydata.net/version.json +++ b/easydata.net/version.json @@ -1,5 +1,5 @@ { - "assemblyVersion": "1.4.9.2", - "packageVersion": "1.4.9-rc02", + "assemblyVersion": "1.4.9.3", + "packageVersion": "1.4.9", "assetVersion": "01_04_09" }