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 Jun 29, 2017 5:12 am

hello

I try input image on multi column.
but There is a problem with the width of the image.

I can't set column padding 1pixel
Cap 2017-06-29 14-01-04-623.png
Cap 2017-06-29 14-01-04-623.png (83.36 KiB) Viewed 3278 times


And i set ExcelPicture Width and Height same pixel value,
but result is not same.

thank you.
Attachments
inputimage_test.zip
(11.16 KiB) Downloaded 284 times

bangley
 
Posts: 4
Joined: Thu Dec 19, 2013 9:00 am

Thu Jun 29, 2017 7:07 am

Dear bangley,

Thanks for your inquiry.
I checked the file you provided, and found you didn't offer the original image separately. So I copy the original image in Excel into Word, then save the image. And I have testing the case you mentioned with Spire.XLS Pack Hotfix Version:7.12.27. And below is my testing code.
Code: Select all
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];
            //the image is saved by MS word
            Image image = Image.FromFile(@"F:\image\10790Excel.png");
            ExcelPicture picture1 = sheet.Pictures.Add(2, 2, image);
            picture1.Width = 126;
            picture1.Height = 126;
            workbook.SaveToFile("10970-1.xlsx", ExcelVersion.Version2013);

The height and width of the image on result file are same. So please try to use this version. If the issue still happens with the version, please provide us with following information for investigation.
1) The original image (and input excel document if any)
2) Whole code you were using
3) OS information, e.g. win7 64bit
4) The DPI setting on the computer
Then we will investigate it and update you ASAP.

Thanks,
Betsy
E-iceblue support team
User avatar

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

Thu Jun 29, 2017 8:31 am

Thank You for reply.

I try code. and it's good work.

but i load "Excelfile created by MsExcel" and run same code.
it have problem.

CreatedBySpire.xlsx → input image → OK (CreatedBySpire_result.xlsx)
CreatedByExcel.xlsx → input image → NG(CreatedByExcel_result.xlsx)

i don't know what's differnt.

1) The original image (and input excel document if any)
i attachment files

2) Whole code you were using
Code: Select all
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"C:\CreatedByExcel.xlsx");
            Worksheet sheet = workbook.Worksheets[0];
            //the image is saved by MS word
            Image image = Image.FromFile(@"C:\_test_img.bmp");
            ExcelPicture picture1 = sheet.Pictures.Add(2, 2, image);
            picture1.Width = 126;
            picture1.Height = 126;

...

            workbook.SaveToFile("CreatedByExcel_result.xlsx", ExcelVersion.Version2013);


3) OS information, e.g. win7 64bit
Windows Pro 7 64bit Japanese
Microsoft Office Standard 2010 Japanese

4) The DPI setting on the computer
windows 7 default ( 96 DPI )

thankyou.
Attachments
InputImage.zip
(25.46 KiB) Downloaded 256 times

bangley
 
Posts: 4
Joined: Thu Dec 19, 2013 9:00 am

Thu Jun 29, 2017 9:17 am

Dear bangley,

Thanks for sharing the files.
I have tested the files with the latest Spire.XLS Pack Hotfix Version:7.12.27(Spire.XLS.dll V7.12.27.6040), the file CreatedByExcel.xlsx can generate the correct result. And I also tested the file with Free Spire.XLS, then I got same result file as yours(CreatedByExcel_result.xlsx), so I suppose you were using free version. Please use the latest version which includes all fixes and new features.
If there is any question, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

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

Thu Jun 29, 2017 10:10 am

dear Betsy.

I'll try latest Spire.XLS Pack Hotfix Version:7.12.27(Spire.XLS.dll V7.12.27.6040) at tomorrow

thank you.

bangley
 
Posts: 4
Joined: Thu Dec 19, 2013 9:00 am

Tue Jul 04, 2017 7:19 am

Dear bangley,

Did you try the latest version ? Did it solve your issue ?
Could you please give us some feedback at your convenience ?

Thanks,
Betsy
E-iceblue support team
User avatar

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

Fri Jul 07, 2017 8:36 am

Dear Betsy

Sorry for late reply.

I tried lastest version.
but still have problem

Cap 2017-07-07 17-21-14-971.png
Cap 2017-07-07 17-21-14-971.png (68.73 KiB) Viewed 3200 times


I think it is a problem with MS Office.

I attachment TestProgram and Project.
please Test it.

Code: Select all
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"CreatedByExcel.xlsx");
Worksheet sheet = workbook.Worksheets[0];

Image image = Image.FromFile(@"300x300.png");

// get col 2~3 pixel width
var width = sheet.GetColumnWidthPixels(2) + sheet.GetColumnWidthPixels(3);

sheet.Range[1, 1].Text = "CreatedByExcel.xlsx";
sheet.Range[2, 2].Text = "Image Padding-Right : 0";
ExcelPicture picture1 = sheet.Pictures.Add(3, 2, image);
picture1.Width = width;
picture1.Height = width;

sheet.Range[11, 2].Text = "Image Padding-Right : 1";
ExcelPicture picture2 = sheet.Pictures.Add(12, 2, image);
picture2.Width = width - 1;
picture2.Height = width - 1;

workbook.SaveToFile("CreatedByExcel_result.xlsx", ExcelVersion.Version2013);


https://drive.google.com/file/d/0B2Xrea ... sp=sharing
https://drive.google.com/file/d/0B2Xrea ... sp=sharing

Thankyou.

bangley
 
Posts: 4
Joined: Thu Dec 19, 2013 9:00 am

Fri Jul 07, 2017 10:02 am

Dear bangley,

Thanks for sharing.
We will test it and update information to you ASAP.

Sincerely,
Betsy
E-iceblue support team
User avatar

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

Mon Jul 10, 2017 3:53 am

Dear bangley,

Sorry for late reply as weekend.
I have noticed the width/heigh of the result image is difference in two result files. And noticed the reason is caused by the value which is different in the code "var width = sheet.GetColumnWidthPixels(2) + sheet.GetColumnWidthPixels(3);". And I have forwarded this issue to our Dev team. Yet, we just simulated the algorithm MS Excel used, and there might be difference. We will adjust our algorithm, and will inform you as soon as there is any progress.
Sorry for the inconvenivence caused.

Sincerely,
Betsy
E-iceblue support team
User avatar

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

Return to Spire.XLS