In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "C# how to customize the paper size of the form when converting Excel to PDF", in the daily operation, I believe that many people have doubts about how to customize the paper size of the form when converting Excel to PDF in C#. The editor consulted all kinds of data and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the question of "how to customize the paper size of the form when C# converts Excel into PDF". Next, please follow the editor to study!
Introduction of dll
In Visual Studio, open solution Explorer and right-click reference
1. Install dll via NuGet (2 ways)
You can open solution Explorer in Visual Studio, right-click "references", "manage NuGet packages", and then search for Spire.XLS installation.
1.2 copy the following to the PM console installation.
Install-Package Spire.XLS-Version 11.11.2
two。 Manually add a dll reference
You can download the package manually, and then extract it to find the Spire.Xls.dll in the BIN folder. Then open solution Explorer in Visual Studio, right-click reference, and add reference to the dll file under the local path BIN folder to the program.
Code and conversion settings
Code ideas:
1. Instantiate the object of the Workbook class, and then call the Workbook.LoadFromFile (string fileName) method to load the Excel document.
two。 Get the object of the Worksheet class through the Workbook.Worksheets property, that is, get the worksheet
3. Customize the width and height of the table by PageSetup.SetCustomPaperSize (float width, float height) method.
4. Finally, the Workbook.SaveToFile (string fileName, FileFormat fileFormat) method is called to save it in PDF format.
C#
Using Spire.Xls;namespace ExcelToPDFwithCustomPageSize {class Program {static void Main (string [] args) {/ / instantiate the object of the Workbook class Workbook workbook = new Workbook (); / / load the Excel test document workbook.LoadFromFile ("test.xlsx"); / / traverse the worksheet for (int item0; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.