修复.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:
parent
b3a3381802
commit
403eae8211
6
WinFormsApp1/Form1.Designer.cs
generated
6
WinFormsApp1/Form1.Designer.cs
generated
@ -1,4 +1,8 @@
|
|||||||
namespace WinFormsApp1
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace WinFormsApp1
|
||||||
{
|
{
|
||||||
partial class Form1
|
partial class Form1
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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
|
namespace WinFormsApp1
|
||||||
{
|
{
|
||||||
public partial class Form1 : Form
|
public partial class Form1 : Form
|
||||||
@ -97,7 +104,7 @@ namespace WinFormsApp1
|
|||||||
// 设置EPPlus许可证上下文
|
// 设置EPPlus许可证上下文
|
||||||
OfficeOpenXml.ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;
|
OfficeOpenXml.ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;
|
||||||
|
|
||||||
var allData = new List<System.Data.DataTable>();
|
var allData = new List<DataTable>();
|
||||||
var headers = new List<string>();
|
var headers = new List<string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -121,7 +128,7 @@ namespace WinFormsApp1
|
|||||||
}
|
}
|
||||||
|
|
||||||
var worksheet = package.Workbook.Worksheets[0]; // 使用第一个工作表
|
var worksheet = package.Workbook.Worksheets[0]; // 使用第一个工作表
|
||||||
var table = new System.Data.DataTable();
|
var table = new DataTable();
|
||||||
|
|
||||||
// 获取表头
|
// 获取表头
|
||||||
if (headers.Count == 0)
|
if (headers.Count == 0)
|
||||||
@ -211,7 +218,7 @@ namespace WinFormsApp1
|
|||||||
// 合并所有数据
|
// 合并所有数据
|
||||||
foreach (var table in allData)
|
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++)
|
for (int col = 0; col < headers.Count; col++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace WinFormsApp1
|
namespace WinFormsApp1
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
@ -8,9 +11,8 @@ namespace WinFormsApp1
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
Application.EnableVisualStyles();
|
||||||
// see https://aka.ms/applicationconfiguration.
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
ApplicationConfiguration.Initialize();
|
|
||||||
Application.Run(new Form1());
|
Application.Run(new Form1());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user