hi,
Please help me how to export map to an image and a selected layer to an image .
and also how to export that map to word , excel and powerpoint.
Regards,
Ravi Bokkala
hi,
Please help me how to export map to an image and a selected layer to an image .
and also how to export that map to word , excel and powerpoint.
Regards,
Ravi Bokkala
Hello Ravi,
Thanks for your post, here is some code can show you how to export google layer to an image, also it will work for other layers:
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
Map1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);
Map1.MapUnit = GeographyUnit.Meter;
GdiPlusGeoCanvas canvas = new GdiPlusGeoCanvas();
GoogleMapsLayer googleLayer = new GoogleMapsLayer();
googleLayer.Open();
Collection<SimpleCandidate> labelsInAllLayers = new Collection<SimpleCandidate>();
Bitmap bitmap = new Bitmap((int)Map1.Width.Value, (int)Map1.Height.Value);
canvas.BeginDrawing(bitmap, Map1.CurrentExtent, GeographyUnit.Meter);
googleLayer.Draw(canvas, labelsInAllLayers);
canvas.EndDrawing();
bitmap.Save(@"C:\Temp\Test.jpg");
googleLayer.Close();
And for your second question, here is the code can show you how to export to excel, but you need to put map control out of UpdatePanel, otherwise it will throw exception.
public void ExportToSpreadsheet(DataTable table, string name)
{
HttpContext context = HttpContext.Current;
context.Response.Clear();
context.Response.ContentType = @"text/csv";
context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + name + ".csv");
foreach (DataColumn column in table.Columns)
{
context.Response.Write(column.ColumnName + ";");
}
context.Response.Write(Environment.NewLine);
foreach (DataRow row in table.Rows)
{
for (int i = 0; i < table.Columns.Count; i++)
{
context.Response.Write(row<i>.ToString().Replace(";", string.Empty) + ";");
}
context.Response.Write(Environment.NewLine);
}
context.Response.End();
}
Any more questions please feel free to let us know.
Regards,
Gary
Using code to deal with the related problem about document processing is too complicated for me. Do you have some nice recoomendations about word processing programs. It will be much better if it is totally manual and can be defined by users according to its programming guides. Any suggestion will be appreciated. Thanks in advance.
Best regards,
Arron
Hi Arron,
Here is an exporter from Codeplex, which can export a DataTable/IEnumerable to Word / Excel / PDF / CSV / HTML / CSV. Please check here for the details: exporter.codeplex.com/
Thanks,
Johnny
If you don’t use third party library, export map to word, pdf, excel is a little difficulty. common code can only save as image, csv (a format can be viewed in excel) and txt.With the help of some power library, convert one file to another format is simply easy, like pdf to word conversion, and some other format.
Hi Jony,
Yes, you are right, we normally use “pdfsharp” to reading or writing pdf format.
Thanks,
Hi, Ravi Bokkala.
As for me, I have seldom tried to export that map to word , excel and powerpoint. I wonder have you ever worked it out? Do I need another 3rd party manual toolkit? When it comes to PDF converting process, I have another question, I wonder have you ever tried to convert pdf to other image files before? As for myself, I am testing the related PDF to PNG converting, PDF to BMP converting , and PDF to JPG converting programs these days. Do you have experience about it? Any suggestion will be appreciated. Thanks in advance.
Best regards,
Pan
Hi Pan,
It looks Ravi Bokkala hadn’t back to read the post, our map only support export to PDF or draw to image, if you need to convert to other format, the 3rd part library or utility is helpful.
Regards,
Don