From 403eae82118b927b81b5e73b0207c92172ac7d40 Mon Sep 17 00:00:00 2001 From: Developer Date: Thu, 20 Nov 2025 14:23:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D.NET=20Framework=204.8?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加必要的using引用(System, System.Windows.Forms, System.Drawing等) - 修复Program.cs中的ApplicationConfiguration.Initialize()为.NET Framework兼容方法 - 简化System.Data.DataTable和System.Data.DataRow类型引用 - 解决Win7兼容性编译错误问题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- WinFormsApp1/Form1.Designer.cs | 6 +++++- WinFormsApp1/Form1.cs | 13 ++++++++++--- WinFormsApp1/Program.cs | 8 +++++--- 3 files changed, 20 insertions(+), 7 deletions(-) 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()); } }