我想在将图像插入Excel工作表后调整图像大小。我正在插入这样的图片:
Excel.Pictures p = myWorkSheet.Pictures(System.Type.Missing) as Excel.Pictures;
Excel.Picture pic = null;
pic = p.Insert(path + pic_name + ".png", System.Type.Missing);
pic.Left = Convert.ToDouble(picPosition.Left);
pic.Top = picPosition.Top;
我试图在插入之前调整图片大小,但它的质量会下降。
答案 0 :(得分:1)
解决!!!我刚才在上面的代码中放了下三行:
pic.ShapeRange.LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoCTrue;
pic.ShapeRange.Width = 170;
pic.ShapeRange.Height = 170;
所以,现在它看起来像这样:
Excel.Pictures p = myWorkSheet.Pictures(System.Type.Missing) as Excel.Pictures;
Excel.Picture pic = null;
pic = p.Insert(path + pic_name + ".png", System.Type.Missing);
pic.ShapeRange.LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoCTrue;
pic.ShapeRange.Width = 170;
pic.ShapeRange.Height = 170;
pic.Left = Convert.ToDouble(picPosition.Left);
pic.Top = picPosition.Top;
并且效果很好。