WpfApp/src/view/CgCgkPage.xaml.cs
2025-10-13 15:00:50 +08:00

35 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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