Excel から画像への変換には、次のコードを使用してください。
注: API ImageOrPrintOptions.SetDesiredSize(int desiredWidth, int desiredHeight) は元のページの縦横比を維持できません。 ページの縦横比を維持するために、新しい API ImageOrPrintOptions.SetDesiredSize(int desiredWidth, int desiredHeight, bool keepAspectRatio) を追加します。
ImageOrPrintOptions imgOpt = new ImageOrPrintOptions();
imgOpt.ImageType = ImageType.Png;
//Currently, the method doesn't keep page aspect ratio.
//We will add a new API for it.
//e.g. ImageOrPrintOptions.SetDesiredSize(int desiredWidth, int desiredHeight, bool keepAspectRatio)
imgOpt.SetDesiredSize(1920, 1080);
Workbook wb = new Workbook("Book1.xlsx");
WorkbookRender wr = new WorkbookRender(wb, imgOpt);
for(int i = 0; i < wr.PageCount; i++)
{
wr.ToImage(i, $"output_{i}.png");
}
const int width = 1920;
const int height = 1080;
using (var presentation = new Presentation("example.pptx"))
{
// fit content to the image size
presentation.SlideSize.SetSize(width, height, SlideSizeScaleType.Maximize);
for (var i = 0; i < presentation.Slides.Count; i++)
{
var slide = presentation.Slides[i];
// render the slide with the desired size
using (var bitmap = slide.GetThumbnail(new Size(width, height)))
{
bitmap.Save($"slide{i + 1}.png", ImageFormat.Png);
}
}
}
The issues you have found earlier (filed as CELLSNET-53252) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi