OWC11 can't display on client browser

  • Thread starter Khurram Shamim Siddiqui
  • Start date
K

Khurram Shamim Siddiqui

HI everyone, this is my first post, so please excuse me if it's already been
answere.
I am using OWC11 for my ASP.Net project with Server-side charting, that is I
am creating graph with ChartSpace1 object and after creating "GIF" file I am
showing it in browser in Image control. But Image(or Graph) is not displayed
on client side. My client PC have Microsoft Office 2003 licencse edition.
Any help will be highly appreciated.
Thanks,
 
E

Eliyahu Goldin

You don't need to create a file. You need to stream the image down to the
client in the HttpResponse.

Eliyahu

"Khurram Shamim Siddiqui" <Khurram Shamim
(e-mail address removed)> wrote in message
news:D[email protected]...
 
K

Khurram Shamim Siddiqui

Thanks for quick reply, I am doing the same, as I mentioned earlier
"creating graph with ChartSpace1 object and after creating "GIF" file I am
showing it in browser in Image control." that is the same technique you
describe, the above described GIF is Streamed to client as an image. Here is
the code below.
'******************************************
Dim categories, values, c
Dim strSavePath As String
Dim DTRecords As DataTable
Dim dRow As DataRow

categories = ""
values = ""

DTRecords = GetCityAmount()

For Each dRow In DTRecords.Rows
categories = categories & dRow("City").ToString & Chr(9)
values = values & dRow("AmountMonthly").ToString & Chr(9)
Next

' Remove the leftover tab character at the end of the strings.
categories = Left(categories, Len(categories) - 1)
values = Left(values, Len(values) - 1)

' Create a chart with one series (called "AmountMonthly").
ChartSpace1.Clear()
ChartSpace1.Charts.Add()
ChartSpace1.Charts(0).SeriesCollection.Add()
Chartspace1.Charts(0).SeriesCollection(0).Caption = "Cities"

'Set the series categories and values using the strings created from
the DataSet.
c = ChartSpace1.Constants
ChartSpace1.Charts(0).SeriesCollection(0).SetData(c.chDimCategories,
c.chDataLiteral, categories)
ChartSpace1.Charts(0).SeriesCollection(0).SetData(c.chDimValues,
c.chDataLiteral, values)

' Set the chart type and format the axis as $.
Chartspace1.Charts(0).Type =
OWC11.ChartChartTypeEnum.chChartTypeBar3D 'c.chChartTypeBarClustered
Chartspace1.Charts(0).Axes(c.chAxisPositionBottom).NumberFormat =
"$#,##0"

strSavePath = Server.MapPath(".") & "\Sample.gif"
Chartspace1.ExportPicture(strSavePath, "gif", 1024, 768)

Image1.ImageUrl = strSavePath
'******************************************
 
E

Eliyahu Goldin

This:
strSavePath = Server.MapPath(".") & "\Sample.gif"
Chartspace1.ExportPicture(strSavePath, "gif", 1024, 768)

Image1.ImageUrl = strSavePath
doesn't work because strSavePath is the local path on the server. It doesn't
exist on the client's machine. If you want your way to work, do just
Image1.ImageUrl = "Sample.gif"

But you should rather do the following:

Response.ContentType= "image/gif";
Response.BinaryWrite((byte[])Chartspace1.GetPicture("gif",1024,768));
Response.End();

and set the ImageUrl to the name of the page that builds the chart.

Eliyahu
 
K

Khurram Shamim Siddiqui

Thats greate its working, I am very grateful.
Thank you very much.

Eliyahu Goldin said:
This:
strSavePath = Server.MapPath(".") & "\Sample.gif"
Chartspace1.ExportPicture(strSavePath, "gif", 1024, 768)

Image1.ImageUrl = strSavePath
doesn't work because strSavePath is the local path on the server. It doesn't
exist on the client's machine. If you want your way to work, do just
Image1.ImageUrl = "Sample.gif"

But you should rather do the following:

Response.ContentType= "image/gif";
Response.BinaryWrite((byte[])Chartspace1.GetPicture("gif",1024,768));
Response.End();

and set the ImageUrl to the name of the page that builds the chart.

Eliyahu

Khurram Shamim Siddiqui said:
Thanks for quick reply, I am doing the same, as I mentioned earlier
"creating graph with ChartSpace1 object and after creating "GIF" file I am
showing it in browser in Image control." that is the same technique you
describe, the above described GIF is Streamed to client as an image. Here
is
the code below.
'******************************************
Dim categories, values, c
Dim strSavePath As String
Dim DTRecords As DataTable
Dim dRow As DataRow

categories = ""
values = ""

DTRecords = GetCityAmount()

For Each dRow In DTRecords.Rows
categories = categories & dRow("City").ToString & Chr(9)
values = values & dRow("AmountMonthly").ToString & Chr(9)
Next

' Remove the leftover tab character at the end of the strings.
categories = Left(categories, Len(categories) - 1)
values = Left(values, Len(values) - 1)

' Create a chart with one series (called "AmountMonthly").
ChartSpace1.Clear()
ChartSpace1.Charts.Add()
ChartSpace1.Charts(0).SeriesCollection.Add()
Chartspace1.Charts(0).SeriesCollection(0).Caption = "Cities"

'Set the series categories and values using the strings created
from
the DataSet.
c = ChartSpace1.Constants

ChartSpace1.Charts(0).SeriesCollection(0).SetData(c.chDimCategories,
c.chDataLiteral, categories)
ChartSpace1.Charts(0).SeriesCollection(0).SetData(c.chDimValues,
c.chDataLiteral, values)

' Set the chart type and format the axis as $.
Chartspace1.Charts(0).Type =
OWC11.ChartChartTypeEnum.chChartTypeBar3D 'c.chChartTypeBarClustered
Chartspace1.Charts(0).Axes(c.chAxisPositionBottom).NumberFormat =
"$#,##0"

strSavePath = Server.MapPath(".") & "\Sample.gif"
Chartspace1.ExportPicture(strSavePath, "gif", 1024, 768)

Image1.ImageUrl = strSavePath
'******************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top