Skip to content

Commit 1b9bcbe

Browse files
Removed forced appending of .xlsx extension to file paths when exporting
Users should have the freedom to export OpenXml documents to paths ending with any extension. Fixes mini-software#942 Signed-off-by: Michele Bastione <michele.bastione@gmail.com>
1 parent 2a2c32a commit 1b9bcbe

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/MiniExcel.OpenXml/Api/OpenXmlExporter.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,12 @@ public async Task<int[]> ExportAsync(string path, object value, bool printHeader
4949
{
5050
if (Path.GetExtension(path).Equals(".xlsm", StringComparison.InvariantCultureIgnoreCase))
5151
throw new NotSupportedException("MiniExcel's Export does not support the .xlsm format");
52-
53-
var filePath = path.EndsWith(".xlsx", StringComparison.InvariantCultureIgnoreCase) ? path : $"{path}.xlsx" ;
5452

5553
#if NET8_0_OR_GREATER
56-
var stream = overwriteFile ? File.Create(filePath) : new FileStream(filePath, FileMode.CreateNew);
54+
var stream = overwriteFile ? File.Create(path) : new FileStream(path, FileMode.CreateNew);
5755
await using var disposableStream = stream.ConfigureAwait(false);
5856
#else
59-
using var stream = overwriteFile ? File.Create(filePath) : new FileStream(filePath, FileMode.CreateNew);
57+
using var stream = overwriteFile ? File.Create(path) : new FileStream(path, FileMode.CreateNew);
6058
#endif
6159
return await ExportAsync(stream, value, printHeader, sheetName, configuration, progress, cancellationToken).ConfigureAwait(false);
6260
}
@@ -71,4 +69,4 @@ public async Task<int[]> ExportAsync(Stream stream, object value, bool printHead
7169

7270
return await writer.SaveAsAsync(progress, cancellationToken).ConfigureAwait(false);
7371
}
74-
}
72+
}

0 commit comments

Comments
 (0)