用于CGM(计算机图形图元文件)格式的.NET或C#库?
有人知道一个.NET C#库,用于在WinForms和Microsoft Service Reports/CrystalReports中显示CGM文件,以便也可以打印吗 如果它还能够将文件转换为jpeg、gif、png等网络友好的图形格式,这将非常有用用于CGM(计算机图形图元文件)格式的.NET或C#库?,.net,.net,有人知道一个.NET C#库,用于在WinForms和Microsoft Service Reports/CrystalReports中显示CGM文件,以便也可以打印吗 如果它还能够将文件转换为jpeg、gif、png等网络友好的图形格式,这将非常有用 这可能是来自的重复问题,但OP没有给出答案,建议的解决方案与.NET也不兼容。我只想与SO分享这一临时破解。如果可能的话,我仍然需要一个合适的库(感谢所有在线提供.NET excel教程的人): 你有没有找到一个非临时的黑客解决方案?我试着把它放
这可能是来自的重复问题,但OP没有给出答案,建议的解决方案与.NET也不兼容。我只想与SO分享这一临时破解。如果可能的话,我仍然需要一个合适的库(感谢所有在线提供.NET excel教程的人):
你有没有找到一个非临时的黑客解决方案?我试着把它放进去,但它似乎没有显示图像,只是说“这个图像当前无法显示。”
using System;
using Excel = Microsoft.Office.Interop.Excel;
using Microsoft.Office.Core;
using System.Drawing;
namespace CGM
{
public class CGMConverter
{
Image _mImage;
public Image Image { get { return _mImage; } }
public CGMConverter(string cgm, float width, float height)
{
object misValue = System.Reflection.Missing.Value;
Excel.Application xlsApp = null;
Excel.Workbook xlsWorkBook = null;
Excel.Worksheet xlsWorkSheet = null;
try
{
xlsApp = new Excel.ApplicationClass();
xlsWorkBook = xlsApp.Workbooks.Add(misValue);
xlsWorkSheet = (Excel.Worksheet)xlsWorkBook.Sheets["sheet1"];
xlsWorkSheet.Shapes.AddPicture(cgm, MsoTriState.msoFalse, MsoTriState.msoTrue, 50, 50, width, height);
xlsWorkSheet.Shapes.Item(0).Copy();
_mImage = System.Windows.Forms.Clipboard.GetImage();
}
catch(Exception e)
{
throw (e);
}
finally
{
xlsApp.DisplayAlerts = false;
xlsApp.Quit();
releaseObject(xlsWorkSheet);
releaseObject(xlsWorkBook);
releaseObject(xlsApp);
}
}
private void releaseObject(object obj)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
obj = null;
}
catch (Exception ex)
{
obj = null;
}
finally
{
GC.Collect();
}
}
}
}