修复.NET Framework 4.8兼容性问题

- 添加必要的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 <noreply@anthropic.com>
This commit is contained in:
Developer 2025-11-20 14:23:05 +08:00
parent b3a3381802
commit 403eae8211
3 changed files with 20 additions and 7 deletions

View File

@ -1,4 +1,8 @@
namespace WinFormsApp1
using System;
using System.Windows.Forms;
using System.Drawing;
namespace WinFormsApp1
{
partial class Form1
{

View File

@ -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<System.Data.DataTable>();
var allData = new List<DataTable>();
var headers = new List<string>();
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++)
{

View File

@ -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());
}
}