MiniExcel/drafts/【ExcelDataReader】Read.linq
2021-03-16 15:27:03 +08:00

33 lines
1.3 KiB
C#

<Query Kind="Program">
<NuGetReference>AngleSharp</NuGetReference>
<NuGetReference>Dapper</NuGetReference>
<NuGetReference>DocumentFormat.OpenXml</NuGetReference>
<NuGetReference>ExcelDataReader</NuGetReference>
<NuGetReference>ExcelDataReader.DataSet</NuGetReference>
<NuGetReference>Newtonsoft.Json</NuGetReference>
<NuGetReference>System.Data.SqlClient</NuGetReference>
<Namespace>Dapper</Namespace>
<Namespace>ExcelDataReader</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>System.Data.SqlClient</Namespace>
<Namespace>System.Net.Http</Namespace>
<Namespace>System.Threading.Tasks</Namespace>
</Query>
void Main()
{
Stopwatch sw = new Stopwatch();
sw.Start();
Console.WriteLine("start memory usage: " + System.Diagnostics.Process.GetCurrentProcess().WorkingSet64 / (1024 * 1024) + $"MB");
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
var path = @"D:\git\MiniExcel\samples\xlsx\OpenXmlSDK_InsertCellValues\OpenXmlSDK_InsertCellValues.xlsx";
using (var stream = File.OpenRead(path))
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
reader.Read();
Console.WriteLine("A1 : " +reader.GetValue(0));
Console.WriteLine("end memory usage: " + System.Diagnostics.Process.GetCurrentProcess().WorkingSet64 / (1024 * 1024) + $"MB & run time : {sw.ElapsedMilliseconds}ms");
}
}