private async void loadButton_Click(object sender, RoutedEventArgs e) { // Capture the current context on UI thread var context = SynchronizationContext.Current; var loadOptions = new XlsxLoadOptions(); loadOptions.ProgressChanged += (eventSender, args) => { // Show progress context.Post(progressPercentage => this.progressBar.Value = (int)progressPercentage, args.ProgressPercentage); // Cancel if requested if (this.cancellationRequested) { args.CancelOperation(); } }; try { var file = await Task.Run(() => ExcelFile.Load("LargeFile.xlsx", loadOptions)); } catch (OperationCanceledException) { // Operation cancelled } }
public static void ReportePDF(List <Playlist> listas) { ReporteExcel(listas, File.Exists(pathExcel) && (File.GetAttributes(pathExcel) & FileAttributes.Archive) == FileAttributes.Archive); SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY"); XlsxLoadOptions loadOptions = new XlsxLoadOptions(); ExcelFile excel = ExcelFile.Load(pathExcel, loadOptions); PdfSaveOptions saveOptions = new PdfSaveOptions(); excel.Save(pathPDF, saveOptions); }
public void Print(string excelFile, string printerName) { //used library is paid one and need to set key before using //consists of limitations SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY"); XlsxLoadOptions loadOptions = new XlsxLoadOptions(); ExcelFile excel = ExcelFile.Load(excelFile, loadOptions); excel.Print(printerName); //save as pdf if print not work //PdfSaveOptions saveOptions = new PdfSaveOptions(); //excel.Save(excelFile, saveOptions); }
public static void ReporteCSV(List <Playlist> listas) { ReporteExcel(listas, File.Exists(pathExcel) && (File.GetAttributes(pathExcel) & FileAttributes.Archive) == FileAttributes.Archive); //Workbook workbook = new Workbook(); //workbook.LoadFromFile(pathExcel); //Worksheet sheet = workbook.Worksheets[0]; //sheet.SaveToFile("ReporteCSV.csv", " ", Encoding.UTF8); SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY"); XlsxLoadOptions loadOptions = new XlsxLoadOptions(); ExcelFile excel = ExcelFile.Load(pathExcel, loadOptions); excel.Save( pathCSV, new CsvSaveOptions(CsvType.SemicolonDelimited) { FormatProvider = CultureInfo.CurrentCulture }); }
private async void loadButton_Click(object sender, EventArgs e) { // Capture the current context on UI thread var context = SynchronizationContext.Current; // Create load options var loadOptions = new XlsxLoadOptions(); loadOptions.ProgressChanged += (eventSender, args) => { var percentage = args.ProgressPercentage; // Invoke on UI thread context.Post(progressPercentage => { // Update UI this.progressBar.Value = (int)progressPercentage; this.percentageLabel.Text = progressPercentage.ToString() + "%"; }, percentage); }; this.percentageLabel.Text = "0%"; // Use tasks to run the load operation in a new thread. var file = await Task.Run(() => ExcelFile.Load("LargeFile.xlsx", loadOptions)); }