Skip to content

Commit

Permalink
Update Magicodes.IE.Tools
Browse files Browse the repository at this point in the history
  • Loading branch information
hueifeng committed Oct 20, 2023
1 parent 08455fd commit 79e8e09
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ public async Task AttrExportWithColFontColorData_Test()
}
}

[Fact(DisplayName = "Linux环境时导出JPG图片到Excel的测试", Timeout = 10000)]
[Fact(DisplayName = "Linux环境时导出JPG图片到Excel的测试", Timeout = 100000)]
public async Task ExportWithJPG_Test()
{
var imagePath = Path.Combine(Directory.GetCurrentDirectory(), "TestFiles", "Images", "zero-DPI.Jpeg");
Expand Down
8 changes: 7 additions & 1 deletion src/Magicodes.IE.Tools/Magicodes.IE.Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Magicodes.IE.Excel" Version="2.7.4.2" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.6" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Magicodes.ExporterAndImporter.Excel\Magicodes.IE.Excel.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="zero-DPI.Jpeg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
58 changes: 29 additions & 29 deletions src/Magicodes.IE.Tools/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Magicodes.Benchmarks.Models;
using System.Threading.Tasks;
using Magicodes.ExporterAndImporter.Excel.Utility;
using System.Dynamic;

namespace Magicodes.IE.Tools
{
Expand All @@ -16,45 +17,44 @@ internal class Program
private readonly static List<ExportTestDataWithAttrs> _exportTestData = new List<ExportTestDataWithAttrs>();
private static async Task Main(string[] args)
{
args = new string[] { "TEST" };
//if (args.Length == 0)
//{
// var versionString = Assembly.GetEntryAssembly()
// .GetCustomAttribute<AssemblyInformationalVersionAttribute>()
// .InformationalVersion
// .ToString();
if (args.Length == 0)
{
var versionString = Assembly.GetEntryAssembly()
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion
.ToString();

// Console.WriteLine($"mie v{versionString}");
// Console.WriteLine("-------------");
// Console.WriteLine("\nGithub:");
// Console.WriteLine(" https://github.com/dotnetcore/Magicodes.IE");
// return;
//}
//else if (args.Any(p => "TEST".Equals(p, StringComparison.CurrentCultureIgnoreCase)))
//{
IExporter exporter = new ExcelExporter();
var data = new List<ExportTestDataWithPicture>
Console.WriteLine($"mie v{versionString}");
Console.WriteLine("-------------");
Console.WriteLine("\nGithub:");
Console.WriteLine(" https://github.com/dotnetcore/Magicodes.IE");
return;
}
else if (args.Any(p => "TEST".Equals(p, StringComparison.CurrentCultureIgnoreCase)))
{
ExcelExporter exporter = new ExcelExporter();
var data = new List<ExportTestDataWithPicture>
{
new ExportTestDataWithPicture
{
Img = "C:\\Users\\hueifeng\\Pictures\\avatar.png",
Text="张三"
Img = Path.Combine(Directory.GetCurrentDirectory(), "zero-DPI.Jpeg"),
Text ="张三"
}
};

Parallel.For(0, 100000, (i) =>
{
data.Add(new ExportTestDataWithPicture
Parallel.For(0, 10, (i) =>
{
Img = "C:\\Users\\hueifeng\\Pictures\\avatar.png",
Text = "张三"
data.Add(new ExportTestDataWithPicture
{
Img = Path.Combine(Directory.GetCurrentDirectory(), "zero-DPI.Jpeg"),
Text = "张三"
});
});
});

var filePath = Path.Combine(System.IO.Directory.GetCurrentDirectory(), "test.xlsx");
var result = await exporter.Export("test.xlsx", data);
Console.WriteLine($"导出成功:{filePath}");
// }
var filePath = Path.Combine(System.IO.Directory.GetCurrentDirectory(), "test.xlsx");
var result = await exporter.Export("test.xlsx", data);
Console.WriteLine($"导出成功:{filePath}");
}
Console.WriteLine("完成");
Console.ReadLine();
}
Expand Down
Binary file added src/Magicodes.IE.Tools/zero-DPI.Jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 79e8e09

Please sign in to comment.