3

Spire dll を使用して Excel ファイルを jpg に変換しようとしています。

だから私はこのようなxlsmファイルを持っています:

ここに画像の説明を入力

このコードを使用して jpg に変換します。

    Workbook workbook = new Workbook();
    workbook.LoadFromFile(@"D:\a.xlsm");
    Worksheet sheet = workbook.Worksheets[1];
    sheet.SaveToImage("exceltoimage.jpg");
    System.Diagnostics.Process.Start("exceltoimage.jpg");

しかし、出力はこのようなものです。一部のセルは変換できません。なぜ私は (#name) を意味するのですか?

ここに画像の説明を入力

私のページにこの警告があります:

ここに画像の説明を入力

4

1 に答える 1

2

私は最終的に Aspose を使用します:

http://www.aspose.com/community/files/51/.net-components/aspose.cells-for-.net/category1129.aspx

例 :

http://www.aspose.com/docs/display/cellsnet/Converting+Worksheet+to+Image

私のサンプルコード:

 Workbook workbook = new Workbook(@"D:\a.xlsm");
            //Get the first worksheet.
            Worksheet sheet = workbook.Worksheets[12];

            //Define ImageOrPrintOptions
            ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
            //Specify the image format
            imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
            //Only one page for the whole sheet would be rendered
            imgOptions.OnePagePerSheet = true;

            //Render the sheet with respect to specified image/print options
            SheetRender sr = new SheetRender(sheet, imgOptions);
            //Render the image for the sheet
            Bitmap bitmap = sr.ToImage(0);

            //Save the image file specifying its image format.
            bitmap.Save(@"d:\SheetImage.jpg");

それは私にとってとてもうまくいきます。

于 2015-05-10T13:14:16.287 に答える