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
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.