Export Chart Border

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Export Chart Border

Post by mikethelad » Fri Jan 04, 2013 3:42 pm

When I am exporting a chart to memorystream and then read it, I am getting a border around the image, any ideas?


System.IO.MemoryStream stream = new System.IO.MemoryStream();
WebChart1.Chart.Export.Image.TIFF.Save(stream);

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Export Chart Border

Post by Sandra » Fri Jan 04, 2013 4:59 pm

Hello mikethelad,

I understand your problem but I can not reproduce it here. Can you explain exactly what are you doing or do you make a simple code, because we can try to find a solution for your problem?

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Export Chart Border

Post by mikethelad » Fri Jan 11, 2013 2:07 pm

Cant supply a project as import in the chart into excel via spreadhseer gear plug in code:-


System.IO.MemoryStream stream = new System.IO.MemoryStream();
WebChart1.Chart.Export.Image.JPEG.Save(stream);
stream.Position = 0;
double width = 500;
double height = 270;

double left = 10;
double top = 25;

worksheet.Shapes.AddPicture(stream.ToArray(), left, top, width, height);

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Export Chart Border

Post by Sandra » Mon Jan 14, 2013 4:07 pm

Hello mikethelad,

I have made a example where I have been working with WorkSheets and export the image to .xls file, but your problem doesn't appear for me:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Microsoft.Office.Interop.Excel.Application excelApp;
        Microsoft.Office.Interop.Excel.Worksheet sheet1;
        Microsoft.Office.Interop.Excel.Workbook workbook1;
        private void InitializeChart()
        {
            //Excel application
            excelApp = new Microsoft.Office.Interop.Excel.Application();
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
            workbook1 = excelApp.Workbooks.Open(@"C:\tmp\TestBook2.xls", 0, false, 5, "", "", false,
            Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", true, false, 0, true, false, false);
            sheet1 = (Microsoft.Office.Interop.Excel.Worksheet)workbook1.Sheets["Sheet1"];
            excelApp.Visible = true;
            tChart1.Aspect.View3D = false;
            tChart1.Width = 500;
            tChart1.Height = 300;
            Steema.TeeChart.Styles.Line line1 = new Line(tChart1.Chart);
            line1.FillSampleValues();
        }     

        private void button1_Click(object sender, EventArgs e)
        {
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
           tChart1.Chart.Export.Image.TIFF.Save(@"C:\tmp\Chart1.tiff");
            stream.Position = 0;
            float width = 500;
            float height = 270;
            float left = 10;
            float top = 25;
           
            sheet1.Shapes.AddPicture(@"C:\tmp\Chart1.tiff", 
            Microsoft.Office.Core.MsoTriState.msoFalse,Microsoft.Office.Core.MsoTriState.msoCTrue, left, top, width, height);
        }
Could you please check if my project works in your end?

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Export Chart Border

Post by mikethelad » Tue Jan 15, 2013 10:10 am

Yes, your code works with no border but this saving the image to c:\temp I don't want this and want to save to memorystream and load from the memorystream

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Export Chart Border

Post by Sandra » Tue Jan 15, 2013 3:42 pm

Hello mikethelad,

My sample is made using code of Microsoft native methods to work with Worksheets and your problem doesn't appear for us. Moreover, you must know the MemoryStream aren't supported using the method of shapes AddPicture that provide Microsoft to treat worksheets.

I have seen that you are working with spreadsheetgear components, these allow you work directly using a MemoryStream, because unlike native methods of Microsoft that only have one overload method, as explain here, the spreadsheetgear components have two overloads methods of Shape AddPictures, AddPicture(String,Double,Double,Double,Double) and AddPicture(Byte[],Double,Double,Double,Double) as you see in next link. For this reason, would very grateful if you can make two simple test:
First:Test if this problem appears for you using the AddPictures() of .Net Framework. Could you please tell us your results?
Second:Test if problem appears without Teechart. You only need use any image, with it create an stream and finally add it in the worksheet, using Shapes AddPicture method. After, check if the border of image appears for you. If image appears with border, it means that the problem isn't of TeeChart, the problem or behavior depends of spreadsheetgear component and I recommend you contact with the technical team to solve your problem.

To make the second test you can do something as next:

Code: Select all

           System.IO.FileStream stream = new System.IO.FileStream(@"..\..\YourImage.jpeg", System.IO.FileMode.Open);
            sheet1.Shapes.AddPicture(stream.ToArray(), left, top, width, height);
Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply