Fix : write to zip, the image format error

This commit is contained in:
Wei 2022-01-20 17:22:04 +08:00
parent 1069afd726
commit 14ee731b64
2 changed files with 2 additions and 3 deletions

View File

@ -200,8 +200,7 @@ namespace MiniExcelLibs.OpenXml
{ {
ZipArchiveEntry entry = _archive.CreateEntry(path); ZipArchiveEntry entry = _archive.CreateEntry(path);
using (var zipStream = entry.Open()) using (var zipStream = entry.Open())
using (StreamWriter writer = new StreamWriter(zipStream, _utf8WithBom)) zipStream.Write(content,0, content.Length);
writer.Write(content);
} }
} }
} }

View File

@ -34,7 +34,7 @@ namespace MiniExcelLibs.Tests
[Fact] [Fact]
public void TestIssue304() public void TestIssue304()
{ {
var image = Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQAAAAA3bvkkAAAAEElEQVR4nGJgAQAAAP//AwAABgAFV7+r1AAAAABJRU5ErkJggg=="); var image = Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAVklEQVR4Xn3PgQkAMQhDUXfqTu7kTtkpd5RA8AInfArtQ2iRXFWT2QedAfttj2FsPIOE1eCOlEuoWWjgzYaB/IkeGOrxXhqB+uA9Bfcm0lAZuh+YIeAD+cAqSz4kCMUAAAAASUVORK5CYII=");
var value = Enumerable.Range(1, 5).Select(s => new { image }); var value = Enumerable.Range(1, 5).Select(s => new { image });
var path = PathHelper.GetRandomPath(); var path = PathHelper.GetRandomPath();
MiniExcel.SaveAs(path, value); MiniExcel.SaveAs(path, value);