using Spire.Xls;//需要NuGet 扩展添加
Workbook book = new Workbook();
book.LoadFromFile(“D:/excel/test1.xlsx”);
Worksheet worksheet =book.Worksheets[0];
int sdf= worksheet.Columns.Count();
int sdf2= worksheet.Rows.Count();
JArray jArray1 = new JArray();
for (int i = 1; i <= worksheet.Rows.Count()-1; i++)
{
JObject jObject = new JObject();
for (int j = 0; j < worksheet.Columns.Count(); j++)
{
jObject.Add(“Coumn_”+j, worksheet.Rows[i].Columns[j].Value);
}
jArray1.Add(jObject);
}
Console.WriteLine(jArray1.ToJsonStr());//自己封装的=》可尝试别的打印方式(不重要)
Console.ReadKey();