windowsforms-17885-controls-and-libraries-map-control-examples-printing-and-exporting-how-to-export-a-map.md
To export a map image to a file, use one of the following methods.
MapControl.ExportToImage - exports the map to an image file;
MapControl.ExportToMht - exports the map to a *.MHT file;
MapControl.ExportToPdf - exports the map to a *.PDF file;
MapControl.ExportToXls - exports the map to a *.XLS file;
MapControl.ExportToXlsx - exports the map to a *.XLSX file;
private void ddbExport_Click(object sender, EventArgs e) {
string filepath = filepathBase + exportFormat.ToString();
switch (exportFormat) {
case (ExportFormat.Image):
mapControl.ExportToImage(filepath, ImageFormat.Jpeg);
break;
case (ExportFormat.Mht):
mapControl.ExportToMht(filepathBase);
break;
case (ExportFormat.Pdf):
mapControl.ExportToPdf(filepathBase);
break;
case (ExportFormat.Xls):
mapControl.ExportToXls(filepathBase);
break;
case (ExportFormat.Xlsx):
mapControl.ExportToXlsx(filepathBase);
break;
default:
MessageBox.Show("Export to a *" + exportFormat.ToString() + " file format is impossible.", "Export to " + exportFormat.ToString());
return;
}
MessageBox.Show("Export to a *" + exportFormat.ToString() + " file is done.", "Export to " + exportFormat.ToString());
}
Private Sub ddbExport_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ddbExport.Click
Dim filepath As String = filepathBase & exportFormat.ToString()
Select Case exportFormat
Case (ExportFormat.Image)
mapControl.ExportToImage(filepath, ImageFormat.Jpeg)
Case (ExportFormat.Mht)
mapControl.ExportToMht(filepathBase)
Case (ExportFormat.Pdf)
mapControl.ExportToPdf(filepathBase)
Case (ExportFormat.Xls)
mapControl.ExportToXls(filepathBase)
Case (ExportFormat.Xlsx)
mapControl.ExportToXlsx(filepathBase)
Case Else
MessageBox.Show("Export to a *" & exportFormat.ToString() & " file format is impossible.", "Export to " & exportFormat.ToString())
Return
End Select
MessageBox.Show("Export to a *" & exportFormat.ToString() & " file is done.", "Export to " & exportFormat.ToString())
End Sub