您的位置:首页 > 文旅 > 旅游 > 哈尔滨网站制作公司电话_东莞vi设计_谷歌关键词排名查询工具_网站优化seo是什么意思

哈尔滨网站制作公司电话_东莞vi设计_谷歌关键词排名查询工具_网站优化seo是什么意思

2025/3/20 10:06:39 来源:https://blog.csdn.net/yongshiqq/article/details/146269723  浏览:    关键词:哈尔滨网站制作公司电话_东莞vi设计_谷歌关键词排名查询工具_网站优化seo是什么意思
哈尔滨网站制作公司电话_东莞vi设计_谷歌关键词排名查询工具_网站优化seo是什么意思

效果如下:

 

using System.Data;
using System.IO;
using System.Windows;
using Microsoft.Win32;
using ExcelDataReader;
using System.Text;
using ClosedXML.Excel;namespace IfoxDemo
{public partial class SimpleWindow : Window{public SimpleWindow(){InitializeComponent();}private void OnSelectFileButtonClick(object sender, RoutedEventArgs e){OpenFileDialog openFileDialog = new OpenFileDialog{Filter = "Excel Files|*.xls;*.xlsx;*.xlsm"};if (openFileDialog.ShowDialog() == true){string filePath = openFileDialog.FileName;System.Data.DataTable dataTable = ReadExcelFile(filePath);//dataGrid.HeadersVisibility = DataGridHeadersVisibility.None; // Hide the header rowdataGrid.ItemsSource = dataTable.DefaultView;}}private void OnSaveFileButtonClick(object sender, RoutedEventArgs e){SaveFileDialog saveFileDialog = new SaveFileDialog{Filter = "Excel Files|*.xlsx",DefaultExt = "xlsx"};if (saveFileDialog.ShowDialog() == true){string filePath = saveFileDialog.FileName;SaveDataGridToExcel(filePath);}}private System.Data.DataTable ReadExcelFile(string filePath){Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read)){using (var reader = ExcelReaderFactory.CreateReader(stream)){var result = reader.AsDataSet();return result.Tables[0];}}}private void SaveDataGridToExcel(string filePath){var dataTable = ((DataView)dataGrid.ItemsSource).ToTable();// Remove the first rowusing (var workbook = new XLWorkbook()){var worksheet = workbook.Worksheets.Add(dataTable, "Sheet1");workbook.SaveAs(filePath);}}}
}
<Window x:Class="IfoxDemo.SimpleWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="SimpleWindow" Height="500" Width="600"><Grid><StackPanel><Button Content="选择Excel文件" Margin="10" Click="OnSelectFileButtonClick"/><Button Content="保存修改后的数据" Margin="10" Click="OnSaveFileButtonClick"/><DataGrid Name="dataGrid" AutoGenerateColumns="True" Margin="10" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" Height="300" CanUserResizeColumns="True" /></StackPanel></Grid>
</Window>

 

 

using System.Collections;
using System.Collections.Generic;
using static IFoxCAD.Cad.OpFilter;namespace IfoxDemo
{public class 生成迷宫{[CommandMethod("xx")]public void Demo(){using var tr = new DBTrans();tr.Database.EraseAll();Env.Editor.WriteMessage("开始生成迷宫1");if (System.Windows.Application.Current == null){new System.Windows.Application { ShutdownMode = ShutdownMode.OnExplicitShutdown };}// 显示WPF窗口System.Windows.Application.Current.Dispatcher.Invoke(() =>{var window = new SimpleWindow();window.ShowDialog();});}}}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com