Convert multiple xlsx files to PDF

I have a WindowsForm Application (C#) in there i have a checkedListBox which i want to at a click of a button convert all checked xlsx file (paths) to convert to PDF files.

How can i do so? i only found the solution to convert by adding the path of the file directly into my program. But this doesn´t really help me

Hi Andreas,

Try this:

private void button1_Click(object sender, EventArgs e)
{
    foreach (string path in this.checkedListBox1.CheckedItems)
    {
        var workbook = ExcelFile.Load(path);

        var pdfOptions = new PdfSaveOptions();
        pdfOptions.SelectionType = SelectionType.EntireFile;

        workbook.Save(Path.ChangeExtension(path, ".pdf"), pdfOptions);
    }
}

I hope it helps.

Regards,
Mario

1 Like