GeomarketingForum.com
Juli 31, 2010, 12:13:36 *
Willkommen Gast. Bitte einloggen oder registrieren.
Haben Sie Ihre Aktivierungs E-Mail übersehen?

Einloggen mit Benutzername, Passwort und Sitzungslänge
News: GfK GeoMarketing Magazine 02/2009
 
   Übersicht   Hilfe Suche Kalender Login Registrieren  
Seiten: [1]
  Drucken  
Autor Thema: HTML-Export  (Gelesen 3536 mal)
fritz
Newbie
*
Beiträge: 10


Profil anzeigen
« am: November 03, 2008, 01:52:48 »

Hallo,

hat jemand eine Lösungsansatz, wie ich den HTML-Export per Programmcode automatisieren kann?

Vielen Dank im Voraus.
Gespeichert
Peter
Full Member
***
Beiträge: 119


Profil anzeigen
« Antwort #1 am: November 04, 2008, 01:26:12 »

Hi Fritz

benutze einfach die Methode

MapLayer..::.CreateHTMLImageMap

Auszug aus der RegioGraph Programmers Referenz
Schau es dir am besten direkt in der hilfe an.
Link ist im Startverzeichnis GfK GeoMarketing / RG Programmier Referenz


Zitat
C#
public int[] CreateHTMLImageMap(
   TextWriter targetWriter,
   string anchorName,
   LayoutDisplayContext ldc,
   string[] tooltipColumnKeys,
   string[] tooltipPrefixes,
   string[] tooltipSuffixes,
   bool createLinks,
   string linkColumnKey,
   string autoLinkPattern,
   bool xhtml,
   string linkTarget,
   Progress outerProgress
)
 
Visual Basic (Declaration)
Public Function CreateHTMLImageMap ( _
   targetWriter As TextWriter, _
   anchorName As String, _
   ldc As LayoutDisplayContext, _
   tooltipColumnKeys As String(), _
   tooltipPrefixes As String(), _
   tooltipSuffixes As String(), _
   createLinks As Boolean, _
   linkColumnKey As String, _
   autoLinkPattern As String, _
   xhtml As Boolean, _
   linkTarget As String, _
   outerProgress As Progress _
) As Integer()
 
Visual C++
public:
array<int>^ CreateHTMLImageMap(
   TextWriter^ targetWriter,
   String^ anchorName,
   LayoutDisplayContext^ ldc,
   array<String^>^ tooltipColumnKeys,
   array<String^>^ tooltipPrefixes,
   array<String^>^ tooltipSuffixes,
   bool createLinks,
   String^ linkColumnKey,
   String^ autoLinkPattern,
   bool xhtml,
   String^ linkTarget,
   Progress^ outerProgress
)
 

Parameters
targetWriter
Type: System.IO..::.TextWriter
Writer the map is written into.
anchorName
Type: System..::.String
The name attribute for the HTML map element, i.e. the anchor that is used to link to the image map from the HTML img element.
ldc
Type: GfK.GeoMarketing.Api..::.LayoutDisplayContext
The layout display context that was used to export the layout image file. Used to ensure identical scaling.
tooltipColumnKeys
Type: array< System..::.String >[]()[]
Column keys of the columns to be used for tooltips in the HTML map. May be null if there are no tooltips.
tooltipPrefixes
Type: array< System..::.String >[]()[]
Prefixes for the tooltips in the HTML map. They are directly prepended to the appropriate table values, without any white space. May be null if there are no prefixes.
tooltipSuffixes
Type: array< System..::.String >[]()[]
Suffixes for the tooltips in the HTML map. They are directly appended to the appropriate table values, without any white space. May be null if there are no suffixes.
createLinks
Type: System..::.Boolean
if set to true hrefs will be inserted into the imagemap.
linkColumnKey
Type: System..::.String
Column key of the column to be used for the links behind the HTML map. If this key is invalid, automatic links are generated instead (see autoLinkPrefix).
autoLinkPattern
Type: System..::.String
If automatic links are generated (see linkColumnKey), this pattern determines the URL of the subpages. {KEY} is replaced by the unique object key, {n} (zero-based) by the n-th line of the tooltips.
xhtml
Type: System..::.Boolean
If true, XHTML 1.0 code is generated (area tags end with a slash). If false, HTML 4.01 code is created (area tags end with an angle bracket only).
linkTarget
Type: System..::.String
The target attribute of the generated links. If set to null oder the empty string, no target attribute is generated.
outerProgress
Type: GfK.GeoMarketing.Shared..::.Progress
Outer progress parameter, if several layouts are exported. This parameter may be null.
Return Value
A list of all object keys that were used in the image map. No special order is guaranteed.
See Also


Siehe auch
Gespeichert
fritz
Newbie
*
Beiträge: 10


Profil anzeigen
« Antwort #2 am: November 04, 2008, 05:39:21 »

Hi Peter,

erst einmal vielen Dank für Deine Antwort.

Ich hab das jetzt mal in VB ausgeführt und bekomme zumindest eine Textdatei mit den Koordinaten der Punkte erzeugt (muss aber noch etwas dran feilen).

Gehe ich recht in der Annahme, dass ich den benötigten HTML-Overhead dann mittels TextWriter.WriteLine selbst hinzufügen
und die zugrundeliegende Grafik mittels SaveToGif ebenfalls separat erzeugen muss?

Ich denke, ich bekomme das schon irgendwie hin, aber vielleicht hat ja jemand schon ein fertiges Beispiel.

Gruß Fritz
Gespeichert
fritz
Newbie
*
Beiträge: 10


Profil anzeigen
« Antwort #3 am: November 13, 2008, 10:11:42 »

... so richtig funktioniert's noch nicht.
Ich hab das in VB ausgeführt und bekomme ein GIF sowie HTM-File raus.
Wenn ich's mit dem Ergebnis des Assistenten vergleiche, sieht es eigentlich schon recht gut aus.

Per Export-Assistent definiere ich sonst die Quickinfos.
Tabellendaten oder URL-Aufruf sind nicht erforderlich.

Das Ergebnis sollte dann so aussehen:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
    <title>
Arbeitsblatt 1
    </title>
    <meta name="Generator" content="GfK GeoMarketing HTML Export">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p align="left">
      <img src="Test.gif" usemap="#imgMap" border="0" width="5740" height="4200" alt="map">
      <map id="imgMap" name="imgMap">
  <area nohref alt="999999999&#13;Max Mustermann" title="999999999 | Max Mustermann" shape="rect" coords="947,4042,969,4063">
</map>
    </p>
  </body>
</html>


Das per Code generierte Ergebnis ist aber folgendes:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
    <title>
Arbeitsblatt 1
    </title>
    <meta name="Generator" content="GfK GeoMarketing HTML Export">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p align="left">
      <img src="Test.gif" usemap="#imgMap" border="0" width="5740" height="4200" alt="map">
      <map id="imgMap" name="imgMap">
  <area nohref alt="" title="" shape="rect" coords="947,4042,969,4063">
</map>
    </p>
  </body>
</html>


Der VB-Code dazu:
Code:
Imports GfK.GeoMarketing.Api
Imports GfK.GeoMarketing.Shared
Imports System.IO
Imports System.Windows.Forms


Module modHTMLExport
    Public Sub Execute_HTML_Export(ByVal myLayout As Layout, ByVal myLayer As MapLayer)
        Dim fileName As String = myLayout.Name
        Dim dirName As String = ""
        Dim szOutput As System.Drawing.Size

        ' Dateinamen/Verzeichnis abfragen
        Using fileDialog As New SaveFileDialog
            With fileDialog
                .FileName = fileName
                .Filter = "HTML (*.htm)|*.htm"
                .Title = "speichern unter"
                If .ShowDialog() = DialogResult.OK Then
                    fileName = Path.GetFileNameWithoutExtension(.FileName)
                    dirName = Path.GetDirectoryName(.FileName)
                Else
                    Exit Sub
                End If
            End With
        End Using

        ' Bild erstellen und verwendete Größe definieren
        Using fs = New FileStream((Path.Combine(dirName, fileName) & ".gif"), FileMode.Create, FileAccess.Write, FileShare.None)
            ' Bildgröße 5940 x 4200 Pixel aus A4-Layout erzeugen:
            szOutput.Height = myLayout.Size.Height / 5
            szOutput.Width = myLayout.Size.Width / 5
            ' Bild (GIF) erstellen
            myLayout.SaveToGif(fs, szOutput.Width, szOutput.Height, 64, True) '64 Farben (1-256 möglich)
        End Using

        Dim ldc As New GfK.GeoMarketing.Api.LayoutDisplayContext
        Dim rcPixel As RECTANGLE = New RECTANGLE(0, 0, szOutput.Width, szOutput.Height) 'Output Rectangle in Pixel Units
        Dim szLayout As System.Drawing.Size = New System.Drawing.Size(myLayout.Width, myLayout.Height) 'Size of Layout in Layout Units (mm/100)
        ldc.Init(rcPixel, szLayout, (ldc.AspectRatio))

        ' HTML-File erstellen
        Dim targetWriter As IO.TextWriter = New StreamWriter(Path.Combine(dirName, fileName) & ".htm", False)
        With targetWriter
            .WriteLine("<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">")
            .WriteLine("<html>")
            .WriteLine("  <head>")
            .WriteLine("    <title>")
            .WriteLine("Vergleich PLZ-Grenzen")
            .WriteLine("    </title>")
            .WriteLine("    <meta name=""Generator"" content=""GfK GeoMarketing HTML Export"">")
            .WriteLine("    <meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"">")
            .WriteLine("  </head>")
            .WriteLine("  <body>")
            .WriteLine("    <p align=""left"">")
            .WriteLine("      <img src=""" & Strings.LCase(fileName) & ".gif"" usemap=""#imgMap"" " & _
                       "border=""0"" width=""" & szOutput.Width & """ height=""" & szOutput.Height & """ alt=""map"">")
        End With

        Dim anchorName As String = "imgMap"
        Dim tooltipColKeys As String() = {"Kennung", "Name1"}
        myLayer.CreateHTMLImageMap(targetWriter, anchorName, ldc, tooltipColKeys, Nothing, Nothing, _
                                   False, "", "", False, "", Nothing)

        ' HTML-File schließen
        With targetWriter
            .WriteLine("    </p>")
            .WriteLine("  </body>")
            .WriteLine("</html>")
            .Close()
        End With
    End Sub
End Module

Ich denke nun, dass ich beim Aufruf der CreateHTMLImageMap-Funktion etwas falsch mache, habe aber auch schon andere Varianten durchprobiert.

Wer hat dazu eine Idee?


(Ganz nebenbei bemerkt:
Unter Win XP und IE wird das Bild gar nicht angezeigt. Das ist aber ein anderes Problem)
Gespeichert
soeren
Newbie
*
Beiträge: 9


Profil anzeigen
« Antwort #4 am: November 24, 2008, 02:27:36 »

Hallo Fritz,

das Problem scheint mir zu sein, dass du die Namen der Spalten statt deren Schlüssel (ein kryptischer numerischer, aber dafür eindeutiger Wert) in die Funktion steckst. Den eindeutigen Schlüssel erhältst du, indem du das Spaltenobjekt über seinen Index aus dem Layer abrufst und dann nach seiner Key-Eigenschaft fragst:

Code:
Dim colKey as String
colKey = myLayer.Layer.Columns[0].Key

(Schreibe normalerweise C#, sei also nicht böse, wenn die Syntax nicht 100% stimmt...)

Wenn du die Positionen der Spalten nicht hast, musst du über alle iterieren und auf Namensgleichheit prüfen.

Hope this helps.

Gruß
Sören
Gespeichert
fritz
Newbie
*
Beiträge: 10


Profil anzeigen
« Antwort #5 am: November 24, 2008, 10:16:06 »

... genau, das war's!
Vielen Dank!

Gruß Fritz
Gespeichert
Seiten: [1]
  Drucken  
 
Gehe zu:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2007, Simple Machines LLC Prüfe XHTML 1.0 Prüfe CSS