MiniExcel icon indicating copy to clipboard operation
MiniExcel copied to clipboard

SaveAsTemplate(...) Error with DapperRow decimal cell.

Open MatiasSchwinch opened this issue 3 years ago • 0 comments

I get an error when I try to pass the information from a stored procedure, to a template, the final excel file does not open correctly and I get the following error: "We have encountered a problem with the content of 'output.xlsx', would you like us to try to retrieve as much content as possible, if you trust the source of this book, click yes"

image

I have found that this error occurs when the data type of the column is decimal, this does not happen when the type is for example string, what could be happening?.

Current culture: es-AR.

Table image

Stored procedure

  SELECT
    CuotaId as Id,
    Numero as Number,
    FechaPago as PaymentDate,
    PagoTotal as Amount,
    Interes as Interest,
    Principal,
    SaleTax
  FROM [**].[**].[Cuota]
  WHERE FechaPago >= @FechaInicio AND FechaPago <= @FechaFinal

Results image

Code

using var connection = new SqlConnection("Server=MGS;Database=**;Trusted_Connection=True;TrustServerCertificate=True;MultipleActiveResultSets=true");
connection.Open();

var list = connection.Query(
			"dbo.obtener_pagos",
			new
			{
				FechaInicio = DateTime.Now.AddDays(-10),
				FechaFinal = DateTime.Now
			},
			buffered: false,
			commandType: CommandType.StoredProcedure);
			
connection.Close();

MiniExcel.SaveAsByTemplate(@"E:\Users\matia\Desktop\output.xlsx", @"E:\Users\matia\Desktop\template_pagos_actualizado.xlsx", new { list, fecha = DateTime.Now });

Excel Type

  • [X] XLSX
  • [ ] XLSM
  • [ ] CSV
  • [ ] OTHER

Upload Excel File

template_pagos_actualizado.xlsx output.xlsx

MiniExcel Version

1.30.1

MatiasSchwinch avatar Feb 19 '23 16:02 MatiasSchwinch