locked
导出excel RRS feed

答案

全部回复

  • sl在处理图片加裁时,用的是什么方法?可以从这里入手吧


    okokwukai
    2010年5月6日 3:05
  •            SaveFileDialog sfd = new SaveFileDialog();
                    sfd.FilterIndex = 1;

                    if (sfd.ShowDialog() == true)
                    {
                        using (Stream stream = sfd.OpenFile())
                        {
                            Save(bitmap, stream);
                        }
                    }

     

        private void SaveToFile(WriteableBitmap bitmap, Stream fs)
            {

               
                int width = bitmap.PixelWidth;
                int height = bitmap.PixelHeight;
                int bands = 3;
                byte[][,] raster = new byte[bands][,];

                for (int i = 0; i < bands; i++)
                {
                    raster[i] = new byte[width, height];
                }

                for (int row = 0; row < height; row++)
                {
                    for (int column = 0; column < width; column++)
                    {
                        int pixel = bitmap.Pixels[width * row + column];
                        raster[0][column, row] = (byte)(pixel >> 16);
                        raster[1][column, row] = (byte)(pixel >> 8);
                        raster[2][column, row] = (byte)pixel;
                    }

                }

                FluxJpeg.Core.ColorModel model = new FluxJpeg.Core.ColorModel { colorspace = FluxJpeg.Core.ColorSpace.RGB };
                FluxJpeg.Core.Image img = new FluxJpeg.Core.Image(model, raster);


               
                //Encode the Image as a JPEG
                MemoryStream stream = new MemoryStream();
                FluxJpeg.Core.Encoder.JpegEncoder encoder = new FluxJpeg.Core.Encoder.JpegEncoder(img, 100, stream);
                encoder.Encode();

           
                stream.Seek(0, SeekOrigin.Begin);


                byte[] binaryData = new Byte[stream.Length];
                long bytesRead = stream.Read(binaryData, 0, (int)stream.Length);
                fs.Write(binaryData, 0, binaryData.Length);

            }

    这是生成图片的FluxJpeg这些都是控件 如何生成或者插入excel呢?

    是Silverlight3

    2010年5月6日 3:29
  • 你好,

         这个用Silverlight4的与com交互的功能来实现的话会比较方便。

         http://forums.silverlight.net/forums/p/160030/359177.aspx   (SL4 例子)

        http://blogs.msdn.com/brada/archive/2009/07/14/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-part-4-seo-export-to-excel-and-out-of-browser.aspx  

       这个是SL3导入到Excel的例子

      

     

    2010年5月13日 2:20