请教高手,如何将excel文件转换为img,有什么方案?有代码请附上,谢谢。

解决方案 »

  1.   

    在一个panel里放个DataGridView,Excel里的东西读到这个DataGridView里,然后把这个Panel里的东西保存成图片 #region 抓屏成图片
            [System.Runtime.InteropServices.DllImport("gdi32.dll ")]
            public static extern long BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
            private Image memoryImage;
            private void CaptureScreen()
            {
                Graphics mygraphics = this.panel_Print.CreateGraphics();//创建的是整个panel
                Size s = this.panel_Print.Size;//取panel大小
                memoryImage = new Bitmap(s.Width, s.Height, mygraphics);
                Graphics memoryGraphics = Graphics.FromImage(memoryImage);
                IntPtr dc1 = mygraphics.GetHdc();
                IntPtr dc2 = memoryGraphics.GetHdc();
                BitBlt(dc2, 0, 0, this.panel_Print.ClientRectangle.Width, this.panel_Print.ClientRectangle.Height, dc1, 0, 0, 13369376);
                mygraphics.ReleaseHdc(dc1);
                memoryGraphics.ReleaseHdc(dc2);
            }
            #endregion