Spire.XLS for .NET is a professional Excel .NET library that can be used to any type of .NET( C#, VB.NET, ASP.NET, .NET Core) application and Java (J2SE and J2EE) application.

Fri Nov 23, 2018 5:23 pm

Hi,

I'm trying to create a Excel document with Spire.XLS but I have a problem when I apply PrintTitleRows to the document.
Next I show you my code
Code: Select all
Workbook excel = new Workbook();
Worksheet full = excel.Worksheets[0];
full.PageSetup.Orientation = PageOrientationType.Landscape;
full.PageSetup.PrintTitleRows = "$1:$9";


The previous code doesn't works.
My code is correct?

Thank you for helping me

alexandrefillat
 
Posts: 3
Joined: Tue Feb 13, 2018 10:06 am

Mon Nov 26, 2018 2:31 am

Hi,

Thanks for your inquiry and sorry for late reply as weekend.
After testing with Spire.Office Platinum (DLL Only) Version:3.11.5, I didn't find there was any issue. Below is my testing code, and I also attached my result file for your kind reference.
Code: Select all
            Workbook excel = new Workbook();
            Worksheet full = excel.Worksheets[0];
            full.PageSetup.Orientation = PageOrientationType.Landscape;
            full.PageSetup.PrintTitleRows = "$1:$9";
            for (int i =1; i < 50; i++)
            {
                full.Range[i, 1].Value = i.ToString();
            }
            excel.SaveToFile("PrintTitleRow15687.xlsx", ExcelVersion.Version2010);
            //set the print setting when printing
            excel.PrintDocument.PrinterSettings.DefaultPageSettings.Landscape = true;
            //print excel
            excel.PrintDocument.Print();

Could you please provide your entire code with us for further investigation.

Sincerely,
Betsy
E-iceblue support team
Attachments
ResultFiles.zip
(153.26 KiB) Downloaded 79 times
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Mon Nov 26, 2018 9:39 am

Hi,

Thank you for your answer, indeed, when I try to print directly from code, the problem doesn't exist, but when I open the document from Microsoft Excel, it doesn't keep the configuration.
When I open the document, in titlesPrint menu, the field 'Rows to repeat at top' appears empty despite "$1:$9".

Code: Select all
 static private void generateExcel()
        {
            Workbook excel = new Workbook();
            Worksheet full = excel.Worksheets[0];
            full.PageSetup.Orientation = PageOrientationType.Landscape;
            full.PageSetup.PrintTitleRows = "$1:$9";

            for (int i =1;i<50;i++)
            {
                full.Range[i, 1].Value = i.ToString();
            }
            excel.SaveToFile(@"c:\test\PrintTitleRow15687.xlsx", FileFormat.Version2013);
            excel.PrintDocument.PrinterSettings.DefaultPageSettings.Landscape = true;
            //print excel
            //excel.PrintDocument.Print();
        }


I found a difference between the document that Spire.Xls generates and the document that Microsoft generates. The difference I found is in the line <definedName name="Print_Titles" localSheetId="0">'Sheet1'!$1:$9</definedName> there are two single quotes.
I have attached xml code for checking the difference. I don't know if this is the problem, but I hope to help to find the solution.

Thank you for helping
Attachments
ok.PNG
ok.PNG (9.53 KiB) Viewed 1125 times
ko.PNG
ko.PNG (7.32 KiB) Viewed 1125 times

alexandrefillat
 
Posts: 3
Joined: Tue Feb 13, 2018 10:06 am

Mon Nov 26, 2018 10:18 am

Hi,

Thanks for your information.
Normally, the single quotes in xml file would not affect the setting "Rows to repeat at top".
When opening the result file in Microsoft Excel, the setting is correct. Below is my screenshot.
OpenInMSExcel.png
OpenInMSExcel.png (31.8 KiB) Viewed 1119 times

Please make sure you select the correct worksheet(sheet1) when checking the setting in Excel. If the issue still exists, please provide following information for further investigation.
1. OS and Region information, e.g. Win7 64bit, China/Chinese.
2. The Excel version like below.
ExcelVersion.png
ExcelVersion.png (14.67 KiB) Viewed 1119 times


Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Mon Nov 26, 2018 1:50 pm

Hi,

I'm opening the document with MS Office 365, and the OS is Windows 10 Enterprise 64bits, Spain/Spanish

I would like to try open with MS Excel 2013 or other different to Office 365, but it is impossible for us, since we don't have licences for that.

On the other hand, I have checked about the selected sheet when I select the 'title rows' menu.

Thank you so much!
Attachments
TitleRow Top.PNG
Title Rows
TitleRow Top.PNG (42.83 KiB) Viewed 1115 times
msExcelv365.PNG
Office version
msExcelv365.PNG (23.54 KiB) Viewed 1115 times

alexandrefillat
 
Posts: 3
Joined: Tue Feb 13, 2018 10:06 am

Tue Nov 27, 2018 6:25 am

Hi,

Thanks for your information.
Kindly note our Spire.XLS follows the standard of MS Excel.
Besides, I have downloaded MS Office 365 and installed it on several computers, then open the result file with MS Office 365 on the computers. I could see the setting value in the result file. Please try to change a computer and open the result file to check if the issue is solved.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Fri Nov 30, 2018 2:29 am

Hi,

Greetings from E-iceblue.
How is your issue going now? Could you please give us some feedback at your convenience?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3067
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS

cron