我記憶體16G run code怎麼會不足呢?
以下我的code:
前面using我就不打了,該加入參考已加入
class Program
{
static void Main(string[] args)
{
object ActivePrinter = (object)"Tagged Images Printer";
object PrintToFile = (object)true;
object PrToFileName = (object)@"D:\DocToImg" + DateTime.Now.Ticks.ToString();
Microsoft.Office.Interop.Excel.Application appExcel = new Microsoft.Office.Interop.Excel.Application();
EXECL.Workbook EXECLwb = appExcel.Workbooks.Open(@"D:\DocToImg\666.xlsx");
EXECLwb.PrintOutEx(ActivePrinter: ActivePrinter, PrintToFile: PrintToFile, PrToFileName: PrToFileName);
EXECLwb.Close();
appExcel.Quit();
System.Drawing.Image img = System.Drawing.Image.FromFile(PrToFileName.ToString()); //卡這裡
img.Save(@"D:\DocToImg\666.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
img.Dispose();
File.Delete(PrToFileName.ToString());
}
}
}
不知道去哪裡看的,
輸出的根本不是圖檔,怎麼能使用 Image.FromFile 呢?
Excel轉圖有個很大的困難,
要怎麼決定列印的範圍呢?
小魚大大,我是看這裡的
http://www.it610.com/article/1459997.htm
他的code有問題囉?
小魚大大,這個我有用,但是卡關...
http://www.cnblogs.com/lyl6796910/archive/2013/01/24/2875799.html
我有修改一下了
object ranobj = Type.Missing;
object ActivePrinter = (object)"Tagged Images Printer";
object PrintToFile = (object)true;
object PrToFileName = (object)@"C:\DocToImg+Interop.PowerPoint-img-{0}.png";
Microsoft.Office.Interop.Excel.Application appExcel = new Microsoft.Office.Interop.Excel.Application();
EXECL.Workbook EXECLwb = appExcel.Workbooks.Open(@"D:\DocToImg\777.xlsx");
EXECLwb.PrintOutEx(ActivePrinter: ActivePrinter, PrintToFile: PrintToFile, PrToFileName: PrToFileName);
System.Drawing.Image img = System.Drawing.Image.FromFile(PrToFileName.ToString());
img.Save(@"D:\DocToImg\777.png", System.Drawing.Imaging.ImageFormat.Png);
img.Dispose();
File.Delete(PrToFileName.ToString());
EXECLwb.Close();
appExcel.Quit();
一樣卡住了....您說的圖檔我有改了