SqlKata 查询导出到 Excel 或转换为表/数据网格

问题描述

我正在开发程序,我需要以某种方式获取 sqlkata 查询并将其转换为表或 DataGrid。

        var db = DatabaseManager.Instance.GetQueryFactory();
        Table table = new Table();
        DataGrid datagrid = new DataGrid();
        
        table = db.Query("data"); //Can I do something like this?
        datagrid = db.Query("data"); //Or this option?
   
        datagrid.SelectAllCells();
        datagrid.ClipboardcopyMode = DataGridClipboardcopyMode.IncludeHeader;
        ApplicationCommands.copy.Execute(null,Grid);
        String resultat = (string)Clipboard.GetData(DataFormats.CommaSeparatedValue);
        String result = (string)Clipboard.GetData(DataFormats.Text);
        datagrid.UnselectAllCells();
        System.IO.StreamWriter file1 = new System.IO.StreamWriter(@"C:\temp\test.xls");
        file1.WriteLine(result.Replace(',',' '));
        file1.Close();

        MessageBox.Show(" Exporting DataGrid data to Excel file created.xls");

或者我可以以某种方式直接将 sqlkata 查询导出到 Microsoft Excel 文件中吗?谢谢大家的回答

图片可以让你更好地理解 - https://prnt.sc/10i2ya0

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)