Мой вопрос: как я могу взять данные из DataGrid и отправить их в таблицу в FastReport? Я вижу, что обычно вам нужен источник данных, подключенный к таблице базы данных, но мне это не нужно. Я просто хочу передать данные из памяти в таблицу в FastReport. Как мне это сделать?
Мой вопрос: как я могу взять данные из DataGrid и отправить их в таблицу в FastReport? Я вижу, что обычно вам нужен источник данных, подключенный к таблице базы данных, но мне это не нужно. Я просто хочу передать данные из памяти в таблицу в FastReport. Как мне это сделать? [code]private void btnPrint_Click(object sender, RoutedEventArgs e){ try { var clientList = dataGridClients.ItemsSource .Cast() .ToList();
if (clientList == null || clientList.Count == 0) { MessageBox.Show("No data available for printing."); return; }
Report report = new Report(); report.Load(@"reports\client_list.frx");
// Register the memory list as a DataSource report.RegisterData(clientList, "Clients"); report.GetDataSource("Clients").Enabled = true;
// Bind the existing DataBand to the DataSource var dataBand = report.FindObject("DataBand1") as FastReport.DataBand; if (dataBand != null) { dataBand.DataSource = report.GetDataSource("Clients"); } else { MessageBox.Show("DataBand1 not found in the report."); return; }
// Prepare and show the report report.Prepare(); string tempPdfPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), $"report_{Guid.NewGuid()}.pdf"); report.Export(new PDFSimpleExport(), tempPdfPath);