我正在开发程序,我需要以某种方式获取 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