35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
|
||
using System.Windows;
|
||
using System.Windows.Controls;
|
||
namespace WpfApp.src.view;
|
||
using WpfApp.Utils;
|
||
using unvell.ReoGrid;
|
||
|
||
|
||
/// <summary>
|
||
/// CgCgkPage.xaml 的交互逻辑
|
||
/// </summary>
|
||
public partial class CgCgkPage : Page
|
||
{
|
||
public CgCgkPage()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
private void OnCgCgkPageButtonClick(object sender, RoutedEventArgs e)
|
||
{
|
||
ExcelHelper.LoadTemplate(IconHelper.GetIconPath("demo.xlsx"));
|
||
ExcelHelper.SelectSheet("表2");
|
||
ExcelHelper.InsertRowData(5, 0, new List<object> { "传感器1", 25.6, 101.3, DateTime.Now });
|
||
ExcelHelper.WriteCell("B2", "测试人员");
|
||
ExcelHelper.WriteCell("C3", DateTime.Now.ToString("yyyy-MM-dd"));
|
||
ExcelHelper.SaveAs(IconHelper.GetIconDirectoryPath() + "\\Excel\\Report_2025_10_13.xlsx");
|
||
|
||
// 在页面控件上显示保存后的 Excel
|
||
grid.Load(IconHelper.GetIconPath("Report_2025_10_13.xlsx"));
|
||
|
||
// 不要 Dispose,否则控件被销毁
|
||
// ExcelHelper.Dispose();
|
||
}
|
||
|
||
} |