• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

C#Excel转图片代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Aspose.Cells;

using Aspose.Cells.Rendering;


 public void ExcelTopngImg(string xlsFile,string picFile)
        {

            Workbook book = new Workbook(xlsFile);

            Worksheet sheet = book.Worksheets[0];
            sheet.PageSetup.LeftMargin = 0;
            sheet.PageSetup.RightMargin = 0;
            sheet.PageSetup.BottomMargin = 0;
            sheet.PageSetup.TopMargin = 0;


            ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

            //imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
            imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;


            imgOptions.OnePagePerSheet = true;

            imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;



            SheetRender sr = new SheetRender(sheet, imgOptions);

            sr.ToImage(0, picFile);

        }
学习更多加资料

 

posted on 2021-12-01 09:03  gisai  阅读(532)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3