42 lines
1.5 KiB
C#
42 lines
1.5 KiB
C#
|
using MigraDoc.DocumentObjectModel.Tables;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Diagnostics;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Components.Nonvisual
|
|||
|
{
|
|||
|
public partial class UserControlConfigurableTableDocument : Component
|
|||
|
{
|
|||
|
public UserControlConfigurableTableDocument()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
}
|
|||
|
|
|||
|
public UserControlConfigurableTableDocument(IContainer container)
|
|||
|
{
|
|||
|
container.Add(this);
|
|||
|
|
|||
|
InitializeComponent();
|
|||
|
}
|
|||
|
|
|||
|
public void SaveToDocument<T>(string filePath, string title,
|
|||
|
List<(double width, string header, string propName)> columns,
|
|||
|
double headerRowHeight, double rowHeight, List<T> data)
|
|||
|
{
|
|||
|
if (string.IsNullOrEmpty(filePath)) throw new ArgumentNullException("Empty string instead of path to file");
|
|||
|
if (string.IsNullOrEmpty(title)) throw new ArgumentNullException("Title string is empty");
|
|||
|
if (data.Count == 0) throw new ArgumentNullException("Data list is empty");
|
|||
|
if (columns.Count == 0) throw new ArgumentNullException("Column info list is empty");
|
|||
|
if (rowHeight == 0D || headerRowHeight == 0D) throw new ArgumentNullException("Row height is empty");
|
|||
|
|
|||
|
SaveToPdf saver = new SaveToPdf();
|
|||
|
|
|||
|
saver.CreateConfigurableTableDocument(filePath, title, columns, headerRowHeight, rowHeight, data);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|