Spire.DataExport for .NET is a 100% pure data .NET library suit for exporting data into MS Word, Excel, RTF, Access, PDF, XPS, HTML, XML, Text, CSV, DBF, SYLK, SQL Script, DIF, Clipboard, etc.
Mon Oct 04, 2010 12:42 pm
Hello,
is it possible with your Controls to convert a xlsx files to a pdf with only printing and 128bit security.
Thanks!
-
pJones
-
- Posts: 1
- Joined: Mon Sep 27, 2010 12:25 pm
Mon Oct 04, 2010 3:57 pm
Yes, you can convert Excel File to PDF just need to do two steps:
1. use OleDbConnection to open the Excel file as a DataSource
2. use Spire.DataExport to export the data to a PDF file.
The method following is a sample, the Excel file D:\temp\DatatableSample.xls is a test file in my computer.
static void ConvertExcelToPDF()
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString
= @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\temp\DatatableSample.xls;Extended Properties=""Excel 8.0""";
OleDbCommand command = new OleDbCommand();
command.CommandText = "select * from [country$A1:E19]";
command.Connection = conn;
conn.Open();
Spire.DataExport.PDF.PDFExport pdfExport1 = new Spire.DataExport.PDF.PDFExport();
pdfExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
pdfExport1.DataFormats.CultureName = "en-US";
pdfExport1.DataFormats.Currency = "c";
pdfExport1.DataFormats.DateTime = "yyyy-M-d H:mm";
pdfExport1.DataFormats.Float = "g";
pdfExport1.DataFormats.Integer = "g";
pdfExport1.DataFormats.Time = "H:mm";
pdfExport1.FileName = Guid.NewGuid() + ".pdf";
pdfExport1.PDFOptions.DataFont.CustomFont = new System.Drawing.Font("Arial", 10F);
pdfExport1.PDFOptions.FooterFont.CustomFont = new System.Drawing.Font("Arial", 10F);
pdfExport1.PDFOptions.HeaderFont.CustomFont = new System.Drawing.Font("Arial", 10F);
pdfExport1.PDFOptions.PageOptions.Format = Spire.DataExport.PDF.PageFormat.User;
pdfExport1.PDFOptions.PageOptions.Height = 11.67;
pdfExport1.PDFOptions.PageOptions.MarginBottom = 0.78;
pdfExport1.PDFOptions.PageOptions.MarginLeft = 1.17;
pdfExport1.PDFOptions.PageOptions.MarginRight = 0.57;
pdfExport1.PDFOptions.PageOptions.MarginTop = 0.78;
pdfExport1.PDFOptions.PageOptions.Width = 10.25;
pdfExport1.PDFOptions.TitleFont.CustomFont = new System.Drawing.Font("Arial", 10F);
pdfExport1.SQLCommand = command;
pdfExport1.SaveToFile();
}
But the Spire.DataExport does not currently support the other 2 requirements 'only printing and 128bit security' .
-
admin
- Site Admin
-
- Posts: 3
- Joined: Thu Jan 01, 1970 12:00 am