diff --git a/WinFormsApp1/Form1.Designer.cs b/WinFormsApp1/Form1.Designer.cs index 55e8dde..921e331 100644 --- a/WinFormsApp1/Form1.Designer.cs +++ b/WinFormsApp1/Form1.Designer.cs @@ -1,4 +1,8 @@ -namespace WinFormsApp1 +using System; +using System.Windows.Forms; +using System.Drawing; + +namespace WinFormsApp1 { partial class Form1 { diff --git a/WinFormsApp1/Form1.cs b/WinFormsApp1/Form1.cs index 16b2e0a..852bfd5 100644 --- a/WinFormsApp1/Form1.cs +++ b/WinFormsApp1/Form1.cs @@ -1,3 +1,10 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using System.Data; + namespace WinFormsApp1 { public partial class Form1 : Form @@ -97,7 +104,7 @@ namespace WinFormsApp1 // 设置EPPlus许可证上下文 OfficeOpenXml.ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial; - var allData = new List(); + var allData = new List(); var headers = new List(); try @@ -121,7 +128,7 @@ namespace WinFormsApp1 } var worksheet = package.Workbook.Worksheets[0]; // 使用第一个工作表 - var table = new System.Data.DataTable(); + var table = new DataTable(); // 获取表头 if (headers.Count == 0) @@ -211,7 +218,7 @@ namespace WinFormsApp1 // 合并所有数据 foreach (var table in allData) { - foreach (System.Data.DataRow row in table.Rows) + foreach (DataRow row in table.Rows) { for (int col = 0; col < headers.Count; col++) { diff --git a/WinFormsApp1/Program.cs b/WinFormsApp1/Program.cs index 1e39c2a..e0472af 100644 --- a/WinFormsApp1/Program.cs +++ b/WinFormsApp1/Program.cs @@ -1,3 +1,6 @@ +using System; +using System.Windows.Forms; + namespace WinFormsApp1 { internal static class Program @@ -8,9 +11,8 @@ namespace WinFormsApp1 [STAThread] static void Main() { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } }