Trying for Setting image in Aspose.cells .NET but the image height is not coming properly

//// product profile Comparison Report Logo appended
string imageUrl = System.Web.HttpContext.Current.Server.MapPath("~/Content/Images/logo.png");
string dataDir = Path.GetFullPath(@“D:\Report_Dwn\”);
int pictureIndex = sheet.Pictures.Add(1, 1, imageUrl);
sheet.Cells.SetRowHeightInch(1, 0.42);
////sheet.Cells.SetColumnWidthInch(1,1.72);
Aspose.Cells.Drawing.Picture sitePicture = sheet.Pictures[pictureIndex];
sitePicture.HeightInch = 0.32;
sitePicture.WidthInch = 1.62;
//// endUntitled.png (69.6 KB)

@susil

Thanks for using Aspose APIs.

Please provide us your logo.png (as you have shown in the code) as well as your expected output Excel file (you can create it manually using MS-Excel). We will test your issue at our end and update you asap.

as per your request here i am forwarding the logo.logo.png (2.4 KB)
and the output excel.
Untitled.png (467.6 KB)

here i am forwarding two images of the real issueUntitled1.png (166.4 KB)
Untitled2.png (209.6 KB)

Thanks,

and one more thing, why aspose site has css issues , every thing coming awkward.

 public void ExportCharts(List<int> str)
        {   
            var workbook = new Workbook();
            var fileName = string.Empty;
            fileName = "Product_Comparison";
            Worksheet sheetReport = workbook.Worksheets[0];
            int sheetIndex = sheetReport.Index;
            Worksheet sheet = workbook.Worksheets[sheetIndex];
            Cells cells = sheet.Cells;

            var sheetStyle = workbook.Styles[workbook.Styles.Add()];
            sheetStyle.ForegroundColor = Color.White;
            sheetStyle.Pattern = BackgroundType.Solid;
            StyleFlag flag = new StyleFlag();
            flag.All = true;
            cells.ApplyStyle(sheetStyle, flag);
            ////Create a style object
            var styleHeader = workbook.Styles[workbook.Styles.Add()];

            ////Sets font attributes
            styleHeader.Font.IsBold = true;
            styleHeader.HorizontalAlignment = TextAlignmentType.Left;
            styleHeader.Font.Color = Color.White;
            styleHeader.ForegroundColor = Color.FromArgb(34, 55, 110);
            styleHeader.Pattern = BackgroundType.Solid;

            var invertHeaderStyle = workbook.Styles[workbook.Styles.Add()];
            invertHeaderStyle.Font.IsBold = true;
            invertHeaderStyle.HorizontalAlignment = TextAlignmentType.Left;
            invertHeaderStyle.Font.Color = Color.FromArgb(34, 55, 110);

            //// product profile Comparison Report Logo appended
            string imageUrl = System.Web.HttpContext.Current.Server.MapPath("~/Content/Images/logo.png");
            string dataDir = Path.GetFullPath(@"D:\\Report_Dwn\\");          
            int pictureIndex = sheet.Pictures.Add(1, 1, imageUrl);
            sheet.Cells.SetRowHeightInch(1, 0.42);
            ////sheet.Cells.SetColumnWidthInch(1,1.72);
            Aspose.Cells.Drawing.Picture sitePicture = sheet.Pictures[pictureIndex];
            sitePicture.HeightInch = 0.32;
            sitePicture.WidthInch = 1.62;
            //// end

            cells["B3"].PutValue("User:");
            cells["B4"].PutValue("Email:");
            cells["B5"].PutValue("Downloaded:");
            cells["B3"].SetStyle(styleHeader);
            cells["B4"].SetStyle(styleHeader);
            cells["B5"].SetStyle(styleHeader, true);
            cells["C3"].PutValue("Susil Kumar", true);
            cells["C4"].PutValue("spadhi@progressivemediagroup.in", true);
            cells["C5"].PutValue(System.DateTime.Now.ToString("dd-MMM-yyyy"));
            cells.Merge(2, 2, 1, 2);
            cells.Merge(3, 2, 1, 2);
            cells.Merge(4, 2, 1, 2);

            workbook.Save(dataDir + fileName + System.DateTime.Now.Millisecond + ".xlsx", FileFormatType.Excel2007Xlsx);
        }

@susil,

Thanks for using Aspose APIs.

It seems to be a bug of older version. Because when we tested your code with the most recent version (download link given below), it gave the correct output Excel file.

Please see the following code which is same as yours with little modifications.

public static void ExportCharts()
{
	var workbook = new Workbook();
	var fileName = string.Empty;
	fileName = "Product_Comparison";
	Worksheet sheetReport = workbook.Worksheets[0];
	int sheetIndex = sheetReport.Index;
	Worksheet sheet = workbook.Worksheets[sheetIndex];
	Cells cells = sheet.Cells;

	var sheetStyle = workbook.Styles[workbook.Styles.Add()];
	sheetStyle.ForegroundColor = Color.White;
	sheetStyle.Pattern = BackgroundType.Solid;
	StyleFlag flag = new StyleFlag();
	flag.All = true;
	cells.ApplyStyle(sheetStyle, flag);
	////Create a style object
	var styleHeader = workbook.Styles[workbook.Styles.Add()];

	////Sets font attributes
	styleHeader.Font.IsBold = true;
	styleHeader.HorizontalAlignment = TextAlignmentType.Left;
	styleHeader.Font.Color = Color.White;
	styleHeader.ForegroundColor = Color.FromArgb(34, 55, 110);
	styleHeader.Pattern = BackgroundType.Solid;

	var invertHeaderStyle = workbook.Styles[workbook.Styles.Add()];
	invertHeaderStyle.Font.IsBold = true;
	invertHeaderStyle.HorizontalAlignment = TextAlignmentType.Left;
	invertHeaderStyle.Font.Color = Color.FromArgb(34, 55, 110);

	//// product profile Comparison Report Logo appended
	string imageUrl = @"F:\Download\logo.png";
	//string dataDir = Path.GetFullPath(@"D:\\Report_Dwn\\");
	int pictureIndex = sheet.Pictures.Add(1, 1, imageUrl);
	sheet.Cells.SetRowHeightInch(1, 0.42);
	////sheet.Cells.SetColumnWidthInch(1,1.72);
	Aspose.Cells.Drawing.Picture sitePicture = sheet.Pictures[pictureIndex];
	sitePicture.HeightInch = 0.32;
	sitePicture.WidthInch = 1.62;
	//// end

	cells["B3"].PutValue("User:");
	cells["B4"].PutValue("Email:");
	cells["B5"].PutValue("Downloaded:");
	cells["B3"].SetStyle(styleHeader);
	cells["B4"].SetStyle(styleHeader);
	cells["B5"].SetStyle(styleHeader, true);
	cells["C3"].PutValue("Susil Kumar", true);
	cells["C4"].PutValue("spadhi@progressivemediagroup.in", true);
	cells["C5"].PutValue(System.DateTime.Now.ToString("dd-MMM-yyyy"));
	cells.Merge(2, 2, 1, 2);
	cells.Merge(3, 2, 1, 2);
	cells.Merge(4, 2, 1, 2);

	workbook.Save(CellsHelper.GetVersion() + "--outputSusil.xlsx",SaveFormat.Xlsx);
}

Here is the screenshot of the output Excel file for a reference.

Yes I also tried with the same new aspose.cell.dll its working fine. But In my company product its an older version of aspose.cell.dll, and you know we can’t change the old dll because so many dependencies and old methods are in use. Is there any other way.

Thanks,

and my version is 5.0.0.0

@susil

Please send me your Visual Studio 2015 Console Application with your Old DLL. I will try to find any workaround for you if possible. If I could not find any workaround, then we are afraid, you will have to upgrade to most recent version. Thanks for your understanding and have a good day.