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.

Tue Oct 04, 2022 6:01 am

Hi

i'm inserting some data - adding new rows, and the header image gets removed from the first page.
i've tried adding the header through code, still the same - after save it gets removed.

i have also just opened the file and saved it back, and still the header gets removed from the first page.

The version i'm using is 12.2.0.0.

thank you

spirezeljc
 
Posts: 6
Joined: Tue Oct 04, 2022 5:54 am

Tue Oct 04, 2022 12:14 pm

Hello,

Thanks for your inquiry.
Are you using the latest version of Spire.Xls? If not, please update to it and have a test, you can download the latest version from the following link. If the issue still exists after update to the latest version, please offer the following messages, thanks for your assistance in advance.
1) Your input document.
2) Your full test code that can reproduce your issue.
3) Application type, such as Console App, .NET Framework 4.8 or JDK 1.8.

Spire.XLS Pack(Hotfix) Version:12.9.2: https://www.e-iceblue.com/Download/down ... t-now.html
Spire.XLS for Java Version:12.9.1: https://www.e-iceblue.com/Download/xls-for-java.html

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Tue Oct 04, 2022 1:45 pm

Hi

Not working

.NET framework console app FW 4.7.2

the code

public void Test_Excel_Spire()
{
string tempExcelPath = @"YOUT PARTH\Sklep o izplačilu delovne uspešnosti (predloga)_2.xlsx";
// write to excel
Workbook workbook = new Workbook();
workbook.LoadFromFile(tempExcelPath);
Worksheet sheet = workbook.ActiveSheet; //.CreateEmptySheet("REPORT");
// tried with and without it
Image image = Image.FromFile(@"YOUR PATH\2TDK_template_pic.jpg");
Worksheet firstShee = workbook.Worksheets[0];
firstShee.PageSetup.LeftHeaderImage = image;
firstShee.PageSetup.LeftHeader = "&G";
// end header image

int row = 28;
int col = 2;

sheet.InsertRow(row, 4);
for (int i = 0; i < 30; i++)
{

//sheet.Copy(sheet.Range[$"A{row}:B{row}"], sheet.Range[$"A{row + 1}:B{row + 1}"], true);

CellRange range = sheet.Range[$"B{row}:C{row}"];
range.BorderAround(LineStyleType.Thin, Color.Black);
range.BorderInside(LineStyleType.Thin, Color.Black);
sheet.SetRowHeight(row, 25);

sheet[row, col].Text = $"random {row}";
sheet[row, col + 1].Text = $"again random {row}";
row++;
}


workbook.SaveToFile(@"YOUR PATH\Sklep o izplačilu delovne uspešnosti (predloga)_2_new.xlsx");
//workbook.Save(); // the same issue
}
Attachments
docs.ZIP
(58.2 KiB) Downloaded 734 times

spirezeljc
 
Posts: 6
Joined: Tue Oct 04, 2022 5:54 am

Wed Oct 05, 2022 2:25 am

Hello,

Thanks for providing further information.
"Different First Page" was checked in your template xlsx file, which caused the issue. After unchecking it, the header image will be rendered on all pages. But when I tested your file with firstSheet.PageSetup.DifferentFirst = 0, it didn't work. I have logged it in our issue tracking system with SPIREXLS-4162. I will inform you once there is any update.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Wed Oct 05, 2022 9:30 am

Hi Amy

It works now.

Thank you

spirezeljc
 
Posts: 6
Joined: Tue Oct 04, 2022 5:54 am

Wed Oct 05, 2022 9:54 am

Thanks for your feedback.
I also inform you when SPIREXLS-4162 is resolved.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Thu Oct 06, 2022 11:16 am

Hi Amy

But what if i need the first page to be different?
Is there a way to set this, or is this a part of SPIREXLS-4162 ticket?

thank you

spirezeljc
 
Posts: 6
Joined: Tue Oct 04, 2022 5:54 am

Fri Oct 07, 2022 2:25 am

Hello,

Thank you for your feedback.
If you want the header of the first page to be different, please use the following code settings. I tested that the code is effective.
Code: Select all
firstSheet.PageSetup.DifferentFirst = 1;

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Fri Oct 07, 2022 6:03 am

Hi Annika

I have tested the code also, but no luck.
the first page header is removed.

Thank you

spirezeljc
 
Posts: 6
Joined: Tue Oct 04, 2022 5:54 am

Fri Oct 07, 2022 6:48 am

Hello,

Thank you for your feedback.
Please note that the content of the first page header needs to be set, but currently the first page header only supports setting text. Please use the following code to achieve your needs.
Code: Select all
 firstSheet.PageSetup.FirstHeaderString = "different first header";
 firstSheet.PageSetup.FirstFooterString = "different first footer";
 firstSheet.PageSetup.FirstPageNumber = 1;

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Fri Oct 07, 2022 10:18 am

Hi Annika

I have transferred the logic to spire.doc.
The excel is probably not a good idea for this.

Thank you

spirezeljc
 
Posts: 6
Joined: Tue Oct 04, 2022 5:54 am

Sat Oct 08, 2022 1:14 am

Hello,

Thank you for your feedback.
If you encounter other issues related to our products in the future, please feel free to contact us.

Have a nice day!

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Fri Oct 21, 2022 7:02 am

Hi,

Thanks for your patient waiting.
Glad to inform you that the reported issue SPIREXLS-4162 has been resolved and the new version (Spire.XLS Pack Version:12.10) is available. Please download it from the following link.
Website download link: https://www.e-iceblue.com/Download/download-excel-for-net-now.html
Nuget download link: https://www.nuget.org/packages/Spire.XLS

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1379
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.XLS