Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Thu Oct 07, 2021 8:56 am

Hi,

I'm creating a c# application and it involves the printing of xlsx document. I'm using the version 11.9.3 of Spire.Xls and it does not have the Workbook.PrintDocument property, or any printing related property, whereas it exists in the version 7.x.x. Can you please help me with this? Thanks in advance

gurdeepsingh1409
 
Posts: 4
Joined: Thu Oct 07, 2021 8:45 am

Thu Oct 07, 2021 10:06 am

Hello,

Thanks for your inquiry!

I tested with both Spire.Xls version 11.9.3 and Spire.Xls version 7.11.49, both of them can print excel with the following code. To help us further look into your issue, please share us with your testing code and the target framework of your project (e.g. .net framework 4.7.2). Thanks in advance.
Code: Select all
                //set the number of copies
                workbook.PrintDocument.PrinterSettings.Copies = 2;
                //set the printer name
                workbook.PrintDocument.PrinterSettings.PrinterName = "Printer Name";
                //set the printer setting for double-sided printing
                workbook.PrintDocument.PrinterSettings.Duplex = System.Drawing.Printing.Duplex.Horizontal;
                //... ...
                workbook.PrintDocument.Print();


Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Thu Oct 07, 2021 10:42 am

Hi Marcia,

I'm trying to create a .Net Core 3.1 web api. PFA the image for the problem I'm facing.
Attachments
SpireXLS.png
SpireXLS.png (6 KiB) Viewed 2267 times

gurdeepsingh1409
 
Posts: 4
Joined: Thu Oct 07, 2021 8:45 am

Fri Oct 08, 2021 1:47 am

Hello,

Thanks for sharing more information!

You are using our Spire.Xls via Nuget, right? Kindly note that the .Net Core project will use the dlls for .netStandard if install the Spire.Xls for net directly from Nuget, and sorry that our netStandard dlls don’t support printing now.

Please uninstall the reference of Spire.Xls, and use Spire.Office.NETCore instead. Or you can download the Spire.XLS Pack(Hotfix) Version:11.9.3 from our website, and then reference the dlls under the folder spire.xls_11.9.3\BIN\netcoreapp3.0 manually.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Sat Oct 09, 2021 5:51 am

Hi,

Thanks for the help. It worked.
I have another query, would this package "Spire.Office.NetCore" work in Linux containers as well? Actually I'm getting an exception when i try to generate xlsx, pdf and csv files on linux container, but it works absolutely fine on Windows.

gurdeepsingh1409
 
Posts: 4
Joined: Thu Oct 07, 2021 8:45 am

Sat Oct 09, 2021 6:07 am

Hello,

Glad to hear that the method is worked!

Yes, our Spire.Office supports to work in Linux containers. Could you please describe the exception you meet in detail? Such as provide us with your error message, the Linux environment information (e.g. CentOS 7.9.2009), the input document(if any) and the testing code to help us further look into your issue.

Thanks in advance!

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Oct 11, 2021 9:34 am

HI,

Basically I'm trying to generate an excel (xlsx), pdf and csv file. It works perfectly fine in windows, but not in linux container (using cloud foundry). It throws an excecption as attached.
Following is the code i use to generate the files:
Code: Select all
wkBook.SaveToFile(filePath); // for xlsx
if (_format.ToLower() == "pdf")
            {
                workbook.SaveToFile(_excelFilePath, FileFormat.PDF);
            }
            else if (_format.ToLower() == "csv")
            {
                workbook.SaveToFile(_excelFilePath, FileFormat.CSV);
            }



And following is the code to install libgdiplus that i used in the docker file. Note : I tried both ways, with and without libgdiplus
Code: Select all
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
RUN apt-get update
RUN apt-get install -y libgdiplus libc6-dev
RUN apt-get install -y libicu-dev libharfbuzz0b libfontconfig1 libfreetype6
Attachments
spire.zip
Exception Details
(1.77 KiB) Downloaded 238 times

gurdeepsingh1409
 
Posts: 4
Joined: Thu Oct 07, 2021 8:45 am

Mon Oct 11, 2021 9:55 am

Hello,

Thanks for sharing more information!

According to the error message you provided, I guess that the issue may be caused by the running program cannot find some part of the 'libgdiplus' dependencies. Please refer to the following code to install the full of 'libgdiplus' dependencies, and then try again.

Code: Select all
# install System.Drawing native dependencies

RUN apt-get update \

    && apt-get install -y --allow-unauthenticated \

        libc6-dev \

        libgdiplus \

        libx11-dev \

    && rm -rf /var/lib/apt/lists/*


Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.XLS