creating multi sheet excel file using classic asp - excel

I am working on a project and I need to create a multi sheet excel file using classic asp.
Here is my code. It makes a multi sheet excel but I cant write anything on sheet 2 or 3:
<%
response.charset = "UTF-8"
Response.Buffer=true
Response.AddHeader "Content-Disposition", "attachment;filename=aaa.xls"
Response.ContentType = "application/vnd.ms-excel"
%>
<HTML xmlns:x="urn:schemas-microsoft-com:office:excel">
<HEAD>
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>sheet1</x:Name>
<x:WorksheetOptions>
<x:Print>
<x:ValidPrinterInfo>
</x:Print>
</x:WorksheetOptions>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>sheet2</x:Name>
<x:WorksheetOptions>
<x:Print>
<x:ValidPrinterInfo>
</x:Print>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
</HEAD>
<BODY>
<TABLE>
<%
dim oConn
Set oConn = Server.CreateObject("ADODB.Connection")
Dim rs, ds
Set rs = Server.CreateObject("ADODB.Recordset")
Response.Write "<tr>"
Response.Write "<td style='border-left:none;border:.5pt solid windowtext;' bgcolor='#CCCCCC' bordercolor='#000000'><b>"
Response.Write "aa"
Response.Write "</b></td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td>"
Response.Write "bb"
Response.Write "</td>"
Response.Write "</tr>"
%>
</TABLE>
</BODY>
</HTML>

I don't think it's possible to create actual .xls / .xlsx files in Classic ASP without a third party component (such as EasyXLS.ExcelDocument).
But what you can do is generate your Excel file using XML markup within Classic ASP, export it with a .xls extension and Excel will convert the file when you open it (after a warning message).
For example:
<%#LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Response.Charset = "UTF-8"
Response.AddHeader "Content-Disposition", "attachment;filename=aaa.xls"
Response.ContentType = "application/vnd.ms-excel"
%><?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>Author Name</Author>
<LastAuthor>Author Name</LastAuthor>
<Created>2020-05-20T13:19:37Z</Created>
<LastSaved>2020-05-20T13:21:04Z</LastSaved>
<Company>Company Name</Company>
<Version>14.00</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<AllowPNG/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>4695</WindowHeight>
<WindowWidth>14355</WindowWidth>
<WindowTopX>360</WindowTopX>
<WindowTopY>105</WindowTopY>
<ActiveSheet>2</ActiveSheet>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"
x:FullRows="1" ss:DefaultRowHeight="15">
<Row>
<Cell><Data ss:Type="String">1A - Sheet 1</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Sheet2">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"
x:FullRows="1" ss:DefaultRowHeight="15">
<Row>
<Cell><Data ss:Type="String">1A - Sheet 2</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Sheet3">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"
x:FullRows="1" ss:DefaultRowHeight="15">
<Row>
<Cell><Data ss:Type="String">1A - Sheet 3</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>6</ActiveRow>
<ActiveCol>3</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
The above example has 3 populated sheets. Best thing to do would be to create a dummy template of the type of Excel layout you're looking to generate, populate the sheets with dummy data and export from Excel using the "XML Spreadsheet" format (which is all I did for the above example). Then use Classic ASP to replace the dummy data with actual data.

Related

XSLT Unexpected token beyond end of expression

This is the source XML file converted from Excel document:
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>Passiflora Cui</Author>
<LastAuthor>Passiflora Cui</LastAuthor>
<Created>2019-06-30T21:49:41Z</Created>
<LastSaved>2019-06-30T21:50:54Z</LastSaved>
<Version>16.00</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<AllowPNG/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>16940</WindowHeight>
<WindowWidth>27640</WindowWidth>
<WindowTopX>5580</WindowTopX>
<WindowTopY>3560</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="12" ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s62">
<Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="4" ss:ExpandedRowCount="5" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="65" ss:DefaultRowHeight="16">
<Column ss:AutoFitWidth="0" ss:Width="74"/>
<Row>
<Cell><Data ss:Type="String">Field1</Data></Cell>
<Cell><Data ss:Type="String">Field2</Data></Cell>
<Cell><Data ss:Type="String">Field3</Data></Cell>
<Cell><Data ss:Type="String">Field4</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">Field1_Data1</Data></Cell>
<Cell ss:StyleID="s62"><Data ss:Type="String">Field2_Data1</Data></Cell>
<Cell><Data ss:Type="String">Field3_Data1</Data></Cell>
<Cell><Data ss:Type="String">Field4_Data1</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">Field1_Data2</Data></Cell>
<Cell ss:StyleID="s62"><Data ss:Type="String">Field2_Data2</Data></Cell>
<Cell><Data ss:Type="String">Field3_Data2</Data></Cell>
<Cell><Data ss:Type="String">Field4_Data2</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">Field1_Data3</Data></Cell>
<Cell ss:StyleID="s62"><Data ss:Type="String">Field2_Data3</Data></Cell>
<Cell><Data ss:Type="String">Field3_Data3</Data></Cell>
<Cell><Data ss:Type="String">Field4_Data3</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">Field1_Data4</Data></Cell>
<Cell ss:StyleID="s62"><Data ss:Type="String">Field2_Data4</Data></Cell>
<Cell><Data ss:Type="String">Field3_Data4</Data></Cell>
<Cell><Data ss:Type="String">Field4_Data4</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>5</ActiveRow>
<ActiveCol>5</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
This is my XSLT, extracted the problem part from a larger one that converts Excel XML file to Word XML file, in which the <a:ext></a:ext> element causes the error:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version = "1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wb="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<xsl:output method = "xml" indent = "yes"/>
<!-- Ignore all free text() nodes -->
<xsl:template match="text()" />
<xsl:template match = "/wb:Workbook/wb:Worksheet/wb:Table">
<pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
<Result>
<xsl:for-each select="wb:Row[position() > 1]">
<Test>
<Field1><xsl:value-of select = "wb:Cell[1]/wb:Data"/></Field1>
<Field2><xsl:value-of select = "wb:Cell[2]/wb:Data"/></Field2>
<Field3><xsl:value-of select = "wb:Cell[3]/wb:Data"/></Field3>
<Field4><xsl:value-of select = "wb:Cell[4]/wb:Data"/></Field4>
</Test>
</xsl:for-each>
</Result>
<!--The following a:ext element is just directly copied to the result, which causes the errors-->
<a:ext uri="{05A4C25C-085E-4340-85A3-A5531E510DB2}">
<thm15:themeFamily xmlns:thm15="http://schemas.microsoft.com/office/thememl/2012/main" name="Office Theme" id="{62F939B6-93AF-4DB8-9C6B-D6C7DFDC589F}" vid="{4A3C46E8-61CC-4603-A589-7422A47A8E4A}"/>
</a:ext>
</pkg:package>
</xsl:template>
</xsl:stylesheet>
The <a:ext></a:ext> element is copied from Word XML and just want to be copied directly to the result. However it reported error that "Unexpected token <name> beyond end of expression", the full error messages are as followed:
Severity: warning
Description: Error in expression 05A4C25C-085E-4340-85A3-A5531E510DB2: Unexpected token <name> beyond end of expression
Start location: 22:0
Severity: warning
Description: Error in expression 62F939B6-93AF-4DB8-9C6B-D6C7DFDC589F: Unexpected token <name> beyond end of expression
Start location: 23:0
Severity: warning
Description: Error in expression 4A3C46E8-61CC-4603-A589-7422A47A8E4A: Unexpected token <name> beyond end of expression
Start location: 23:0
How to solve this issue? Thanks in advance for any help!
Curly braces in attributes indicate that the contents are to be treated as XPATH expressions to be evaluated. To get what you want you need to double the braces to escape them:
<a:ext uri="{{05A4C25C-085E-4340-85A3-A5531E510DB2}}">
<thm15:themeFamily
xmlns:thm15="http://schemas.microsoft.com/office/thememl/2012/main"
name="Office Theme"
id="{{62F939B6-93AF-4DB8-9C6B-D6C7DFDC589F}}"
vid="{{4A3C46E8-61CC-4603-A589-7422A47A8E4A}}"/>
</a:ext>

XSLT for selecting specific values in filtered nodes

I have a XML structure where i need to apply filtering for nodes and out of the filtered nodes i need to select specific elements. The structure of actual XML looks like this-
<Host>
<element1>type0</element1>
<element2>Fruits</element2>
....
<elementn>Price0</elementn>
<Menu>
<NodeA>
<element1>type1</element1>
<element2>Fruits</element2>
....
<elementn>Price1</elementn>
<Menu>
<NodeB>
<element1>type2</element1>
<element2>Fruits</element2>
....
<elementn>Price2</elementn>
<Menu>
<NodeC>
<element1>type3</element1>
<element2>Fruits</element2>
....
<elementn>Price3</elementn>
<Menu>
<NodeD>
<Element1>type4</element1>
<Element2>Vegetables</Element2>
....
<Elementn>Price4</elementn>
</NodeD>
</Menu>
</NodeC>
</Menu>
</NodeB>
</Menu>
</NodeA>
<NodeE>
<element1>type5</element1>
<element2>Fruits</element2>
....
<elementn>Price5</elementn>
<Menu>
<NodeF>
<element1>type6</element1>
<element2>Vegetables</element2>
....
<elementn>Price6</elementn>
</NodeF>
</Menu>
</NodeE>
</Menu>
</Host>
Now I have filtered this XML as follows-
a) if <element2> == fruits in all the nodes, the XML result is -
<Host>
<element1>type0</element1>
<element2>Fruits</element2>
....
<elementn>Price0</elementn>
<NodeA>
<element1>type1</element1>
<element2>Fruits</element2>
....
<elementn>Price1</elementn>
</NodeA>
<NodeB>
<element1>type2</element1>
<element2>Fruits</element2>
....
<elementn>Price2</elementn>
</NodeB>
<NodeC>
<element1>type3</element1>
<element2>Fruits</element2>
....
<elementn>Price3</elementn>
</NodeC>
<NodeE>
<element1>type5</element1>
<element2>Fruits</element2>
....
<elementn>Price5</elementn>
</NodeE>
</Host>
XSLT used for getting the above result is-
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:param name="element2" select="'Fruits'" />
<xsl:template match="/*">
<xsl:copy>
<xsl:apply-templates select="//*[element2=$element2]" mode="copy"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[element2]" mode="copy">
<xsl:copy>
<xsl:apply-templates select="*[not(*)]" mode="copy"/>
</xsl:copy>
</xsl:template>
<xsl:template match="#*|node()" mode="copy">
<xsl:copy>
<xsl:apply-templates select="#*|node()" mode="copy"/>
</xsl:copy>
</xsl:template>
The above XSLT select all the elements in the node where <element2> = Fruits condition is applied. Now I need to select specific elements in each filtered node (<Host>, <NodeA>, <NodeB>, <NodeC>, <NodeE>) - say for every node, i have elements range from to . Now I want to select only and from filtered nodes (<Host>, <NodeA>, <NodeB>, <NodeC>, <NodeE>). Also the expected output format is given below. The two values in each given below is from and of each node.
<html>
<head>
<body>
<table border="1">
<tr>
<td>type0</td>
<td>Price0</td>
</tr>
<td>type1</td>
<td>Price1</td>
</tr>
<tr>
<td>type2</td>
<td>Price2</td>
</tr>
<tr>
<td>type3</td>
<td>Price3</td>
</tr>
<tr>
<td>type5</td>
<td>Price5</td>
</tr>
</table>
</body>
</head>
</html>
Any help would be a great plus.
It seems you want to do something like:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="element2" select="'Fruits'" />
<xsl:template match="/">
<html>
<head/>
<body>
<table border="1">
<xsl:for-each select="//*[element2=$element2]">
<tr>
<td>
<xsl:value-of select="element1" />
</td>
<td>
<xsl:value-of select="elementn" />
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
When this is applied to the following well-formed (!) input:
XML
<Host>
<element1>type0</element1>
<element2>Fruits</element2>
<elementn>Price0</elementn>
<Menu>
<NodeA>
<element1>type1</element1>
<element2>Fruits</element2>
<elementn>Price1</elementn>
<Menu>
<NodeB>
<element1>type2</element1>
<element2>Fruits</element2>
<elementn>Price2</elementn>
<Menu>
<NodeC>
<element1>type3</element1>
<element2>Fruits</element2>
<elementn>Price3</elementn>
<Menu>
<NodeD>
<element1>type4</element1>
<element2>Vegetables</element2>
<elementn>Price4</elementn>
</NodeD>
</Menu>
</NodeC>
</Menu>
</NodeB>
</Menu>
</NodeA>
<NodeE>
<element1>type5</element1>
<element2>Fruits</element2>
<elementn>Price5</elementn>
<Menu>
<NodeF>
<element1>type6</element1>
<element2>Vegetables</element2>
<elementn>Price6</elementn>
</NodeF>
</Menu>
</NodeE>
</Menu>
</Host>
the result will be:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<table border="1">
<tr>
<td>type0</td>
<td>Price0</td>
</tr>
<tr>
<td>type1</td>
<td>Price1</td>
</tr>
<tr>
<td>type2</td>
<td>Price2</td>
</tr>
<tr>
<td>type3</td>
<td>Price3</td>
</tr>
<tr>
<td>type5</td>
<td>Price5</td>
</tr>
</table>
</body>
</html>
rendered as:

How to save excel file in Classic ASP

I create an excel file in ASP with:
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=excel.xls"
Response.ContentType = "application/download"
It's possible to SAVE the xls file on server - to download next?
another question - When I open the xls file on excel I receive an error about the file format. why?
the code:
<html xmlns:x="urn:schemas-microsoft-com:office:excel">
<head>
<style>
<!--
#page
{
mso-header-data:"&CDate\: &D\000A<%=strHeader%>";
mso-footer-data:"&CPage &P";
mso-page-orientation:landscape;
margin:1in .3in .6in .4in;
}
br
{
mso-data-placement:same-cell;
mso-width-source:auto;
}
.wborder {
border-color: #FFF;
}
-->
</style>
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>EXCEL</x:Name>
<x:WorksheetOptions>
<x:Print>
<x:ValidPrinterInfo/>
</x:Print>
<x:Panes>
<x:Pane>
<x:Number>3</x:Number>
</x:Pane>
</x:Panes>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml><![endif]-->
</head>
<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<table border="1">
<tr>
<td class="wborder" width="100"></td>
</tr>
</table>
</body>
</html>
tks!!

Using local images in Google Earth

I have 100's of points that have a photo for each of the points that are stored on my local drive. Each point has extended data, which includes the root of the picture name (bee-tree)
I have my set up to reference using this line: img src="/files/$[geotourism_points/PIC_NAME].png", which works when I save it as a kml. However, when I save it as a .kmz it ignores the $[geotourism_points/ and only returns img src="files/PIC_NAME].png"
I have tried using relative path names using ../files/image.png, /files/image.png, files/image.png (which one do you use?!!)
I still can't get it to work. Can I insert images into my balloon this way (local files), or will I have to load these to a server and reference them using the URL?
Thanks in advance for your help!
Here is the whole code:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>KmlFile</name>
<Schema name="geotourism_points" id="geotourism_points_schema">
<SimpleField type="string" name="MO_REGIO_1"><displayName><b>MO_REGIO_1</b></displayName>
</SimpleField>
<SimpleField type="string" name="TYPE"><displayName><b>TYPE</b></displayName>
</SimpleField>
<SimpleField type="string" name="NOTES_1"><displayName><b>NOTES_1</b></displayName>
</SimpleField>
<SimpleField type="string" name="WEBSITE"><displayName><b>WEBSITE</b></displayName>
</SimpleField>
<SimpleField type="string" name="SITE_NAME"><displayName><b>SITE_NAME</b></displayName>
</SimpleField>
<SimpleField type="string" name="LINK_2"><displayName><b>LINK_2</b></displayName>
</SimpleField>
<SimpleField type="string" name="ADDRESS"><displayName><b>ADDRESS</b></displayName>
</SimpleField>
<SimpleField type="string" name="PHONE"><displayName><b>PHONE</b></displayName>
</SimpleField>
<SimpleField type="string" name="PIC_NAME"><displayName><b>PIC_NAME</b></displayName>
</SimpleField>
<SimpleField type="string" name="SOURCE_1"><displayName><b>SOURCE_1</b></displayName>
</SimpleField>
<SimpleField type="int" name="NATUR"><displayName><b>NATUR</b></displayName>
</SimpleField>
<SimpleField type="int" name="CULTU"><displayName><b>CULTU</b></displayName>
</SimpleField>
<SimpleField type="int" name="REC"><displayName><b>REC</b></displayName>
</SimpleField>
<SimpleField type="int" name="ARCHEO"><displayName><b>ARCHEO</b></displayName>
</SimpleField>
<SimpleField type="int" name="HIST"><displayName><b>HIST</b></displayName>
</SimpleField>
<SimpleField type="double" name="OBJECTID"><displayName><b>OBJECTID</b></displayName>
</SimpleField>
</Schema>
<StyleMap id="pointStyleMap">
<Pair>
<key>normal</key>
<styleUrl>#normPointStyle</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#normPointStyle0</styleUrl>
</Pair>
</StyleMap>
<Style id="normPointStyle0">
<IconStyle>
<Icon>
<href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png</href>
</Icon>
</IconStyle>
<BalloonStyle>
<text><![CDATA[<table width="350" cellpadding="1" cellspacing="0">
<tr>
<td colspan="3" align="center" valign="top">
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td align="left" valign="top">
<img src="files/lecl_logo.png" alt="logo"/>
</td>
<td width="70%"" align="left" valign="bottom">
<font color="#2f4f4f" size="+2"><strong>$[geotourism_points/SITE_NAME]</strong></font>
<br>
<font color="#999999"><em>$[geotourism_points/TYPE] </em></font>
<hr/>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">
<p>
<br>
<font color="#666666"><strong>Visitor's Information:</strong></font>
<br><br>
<font color="#999999">$[geotourism_points/ADDRESS]<br>$[geotourism_points/PHONE]</font>
</p>
<p>
<strong><em><font color="#2f4f4f">More Information...</font></strong></em>
</p>
</td>
<td align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="3" bgcolor="white">
<tr>
<td align="center"><img src="files/$[geotourism_points/PIC_NAME].png" alt="picture" width="100%" align="left" valign="middle"/></td>
</tr>
<tr>
<td colspan="3" align="right"><font color="#999999" size="-1">$[geotourism_points/SOURCE_1]</font></td>
</tr>
</td>
</table>]]></text>
</BalloonStyle>
</Style>
<Style id="normPointStyle">
<IconStyle>
<Icon>
<href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png</href>
</Icon>
</IconStyle>
<BalloonStyle>
<text><![CDATA[<table width="350" cellpadding="1" cellspacing="0">
<tr>
<td colspan="3" align="center" valign="top">
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td align="left" valign="top">
<img src="files/lecl_logo.png" alt="logo"/>
</td>
<td width="70%"" align="left" valign="bottom">
<font color="#2f4f4f" size="+2"><strong>$[geotourism_points/SITE_NAME]</strong></font>
<br>
<font color="#999999"><em>$[geotourism_points/TYPE] </em></font>
<hr/>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">
<p>
<br>
<font color="#666666"><strong>Visitor's Information:</strong></font>
<br><br>
<font color="#999999">$[geotourism_points/ADDRESS]<br>$[geotourism_points/PHONE]</font>
</p>
<p>
<strong><em><font color="#2f4f4f">More Information...</font></strong></em>
</p>
</td>
<td align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="3" bgcolor="white">
<tr>
<td align="center"><img src="files/$[geotourism_points/PIC_NAME].png" alt="picture" width="100%" align="left" valign="middle"/></td>
</tr>
<tr>
<td colspan="3" align="right"><font color="#999999" size="-1">$[geotourism_points/SOURCE_1]</font></td>
</tr>
</td>
</table>]]></text>
</BalloonStyle>
</Style>
<Folder id="layer 0">
<name>geotourism_points</name>
<open>1</open>
<Placemark>
<name>Bee Tree County Park</name>
<styleUrl>#pointStyleMap</styleUrl>
<ExtendedData>
<SchemaData schemaUrl="#geotourism_points_schema">
<SimpleData name="MO_REGIO_1">Confluence Region</SimpleData>
<SimpleData name="TYPE">City/County Park</SimpleData>
<SimpleData name="NOTES_1">riverfront</SimpleData>
<SimpleData name="WEBSITE">stlouisco.com/ParksandRecreation/ParkPages/BeeTree</SimpleData>
<SimpleData name="SITE_NAME">Bee Tree County Park</SimpleData>
<SimpleData name="LINK_2"></SimpleData>
<SimpleData name="ADDRESS">2701 Finestown Road Saint Louis, MO 63129</SimpleData>
<SimpleData name="PHONE"></SimpleData>
<SimpleData name="PIC_NAME">bee-tree</SimpleData>
<SimpleData name="SOURCE_1">stlouisco.com</SimpleData>
<SimpleData name="NATUR">1</SimpleData>
<SimpleData name="CULTU">0</SimpleData>
<SimpleData name="REC">1</SimpleData>
<SimpleData name="ARCHEO">0</SimpleData>
<SimpleData name="HIST">0</SimpleData>
<SimpleData name="OBJECTID">234</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-90.32844745921075,38.40766261103909,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Old St. Ferdinand Shrine</name>
<styleUrl>#pointStyleMap</styleUrl>
<ExtendedData>
<SchemaData schemaUrl="#geotourism_points_schema">
<SimpleData name="MO_REGIO_1">Confluence Region</SimpleData>
<SimpleData name="TYPE">Historic Site</SimpleData>
<SimpleData name="NOTES_1"></SimpleData>
<SimpleData name="WEBSITE">http://www.oldstferdinandshrine.com/</SimpleData>
<SimpleData name="SITE_NAME">Old St. Ferdinand Shrine</SimpleData>
<SimpleData name="LINK_2"></SimpleData>
<SimpleData name="ADDRESS">#1 rue St. Francois, Florissant MO 63031</SimpleData>
<SimpleData name="PHONE">Phone: (314) 837-2110</SimpleData>
<SimpleData name="PIC_NAME">old-st-ferdinand-shrine</SimpleData>
<SimpleData name="SOURCE_1">viewfrombackpew.blogspot.com</SimpleData>
<SimpleData name="NATUR">0</SimpleData>
<SimpleData name="CULTU">0</SimpleData>
<SimpleData name="REC">0</SimpleData>
<SimpleData name="ARCHEO">0</SimpleData>
<SimpleData name="HIST">1</SimpleData>
<SimpleData name="OBJECTID">269</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-90.33389390094645,38.79675526749391,0</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
Depends on your target audience. Do want to share KMZ on Internet or on an internal web site with photos on a shared network drive, etc?
If the KMZ file is local and relative to the KMZ file is the folder "files" with all your photos then it will display correctly in Google Earth as-is.
If you're serving the KMZ file from a website and the files are local then it won't work. The images must be co-resident with the KML file if using relative links.
<img src="files/$[geotourism_points/PIC_NAME].png" alt="picture" .../>
If you use absolute URLs in KML to the photo location then the KMZ will work where ever you host it.
<img src="http://server/files/$[geotourism_points/PIC_NAME].png" alt="picture" .../>
Alternative is embed the "files" folder and photos within the KMZ so the KML and photos are self-contained. Then you can use relative links in the KML.

Balloons in Google Earth are not pointing at right location on line

In Google Earth, my balloons are not pointing at the correct location on my line when they open. They are waaaay off. I read a few places that this can be fixed by adding a point to a multigeometry placemark and it will point to that instead. But it's not working! Is there a fix to this? I am using a mac and Google Earth 7.1
Thanks,
Ellen
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>KmlFile</name>
<Schema name="Gorge_Trails" id="Trails_Schema_id">
<SimpleField type="string" name="Trail_number"><displayName><b>Trail_number</b></displayName>
</SimpleField>
<SimpleField type="string" name="Trail_name"><displayName><b>Trail_name</b></displayName>
</SimpleField>
<SimpleField type="string" name="Location"><displayName><b>Location</b></displayName>
</SimpleField>
<SimpleField type="string" name="Difficulty"><displayName><b>Difficulty</b></displayName>
</SimpleField>
<SimpleField type="string" name="Picture_URL"><displayName><b>Picture_URL</b></displayName>
</SimpleField>
<SimpleField type="string" name="Link1"><displayName><b>Link1</b></displayName>
</SimpleField>
<SimpleField type="string" name="Link2"><displayName><b>Link2</b></displayName>
</SimpleField>
<SimpleField type="string" name="Photo_credit"><displayName><b>Photo_credit</b></displayName>
</SimpleField>
<SimpleField type="double" name="Hike_Dist"><displayName><b>Hike_Dist</b></displayName>
</SimpleField>
<SimpleField type="string" name="Trailhead"><displayName><b>Trailhead</b></displayName>
</SimpleField>
<SimpleField type="string" name="Type"><displayName><b>Type</b></displayName>
</SimpleField>
<SimpleField type="double" name="TR_Length"><displayName><b>TR_Length</b></displayName>
</SimpleField>
<SimpleField type="string" name="Hike_Name"><displayName><b>Hike_Name</b></displayName>
</SimpleField>
<SimpleField type="string" name="State"><displayName><b>State</b></displayName>
</SimpleField>
<SimpleField type="string" name="Elevation1"><displayName><b>Elevation1</b></displayName>
</SimpleField>
<SimpleField type="string" name="Hike_Dis_1"><displayName><b>Hike_Dis_1</b></displayName>
</SimpleField>
</Schema>
<Style id="Hikes_highlight_traillink">
<IconStyle>
<color>0000ffff</color>
<scale>0.1</scale>
</IconStyle>
<BalloonStyle>
<text><![CDATA[<table border="0">
<table width="250" border="0" cellspacing="0" cellpadding="1" bgcolor="#e8e9cb" align="center">
<tr>
<td colspan="2" align="center">
<img src="http://gorgefriends.org/img/gorge_index_02.gif" alt="picture" width="100%" height="50"/>
</td>
</tr>
<tr>
<td colspan="2" align="center" valign="bottom" cellpadding="1">
<font color='#3a493e'size=+2> <b>$[Gorge_Trails/Hike_Name]</b></font>
<tr>
<td colspan="2" align="center" valign="bottom" cellpadding="1">
<font color='#3a493e' size=+1 <b>$[Gorge_Trails/Location], $[Gorge_Trails/State]</b></font>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<img src=$[Gorge_Trails/Picture_URL] alt="picture" width="100%" height="140"/>
</td>
<tr>
<td colspan="2" align="center">
<font color="#999999" size="1">Photo:$[Gorge_Trails/Photo_credit]</font>
</td>
</tr>
<table width="250" border="0" cellspacing="3" cellpadding="0" bgcolor="#e8e9cb" align="center">
<tr><td><b>Trailhead</b></td><td>$[Gorge_Trails/Trailhead]</td></tr>
<tr><td><b>Hike Distance</b></td><td>$[Gorge_Trails/Hike_Dist] miles</td></tr>
<tr><td><b>Difficu
lty</b></td><td>$[Gorge_Trails/Difficulty]</td></tr>
<tr><td><b>Type</b></td><td>$[Gorge_Trails/Type]</td></tr>
<tr><td><b>Trail Name</b></td><td>$[Gorge_Trails/Trail_name]</td></tr>
<table width="250" border="0" cellspacing="4" cellpadding="0" bgcolor="#e8e9cb" align="center">
<tr><td><font color=#993300>Rails-to-Trails</font color>
</td></tr>
<table width="250" border="0" cellspacing="1" cellpadding="0" bgcolor="#e8e9cb" align="center"> <tr>
<td colspan="2" align="center" valign="bottom">
<font color="#999999" size="1">Copyright: Friends of the Columbia Gorge/Portlandhikers.org is a proud partner of the</font> Gorge Towns to Trails Initiative</font>
</td>
</tr>
</table>]]></text>
<bgColor>ff689a9a</bgColor>
</BalloonStyle>
<ListStyle>
<maxSnippetLines>0</maxSnippetLines>
</ListStyle>
<LineStyle>
<color>ff1eede9</color>
<width>4</width>
</LineStyle>
</Style>
<Style id="Hikes_normal_traillink">
<IconStyle>
<color>0000ffff</color>
<scale>0.1</scale>
</IconStyle>
<LabelStyle>
<scale>0</scale>
</LabelStyle>
<BalloonStyle>
<text><![CDATA[<table border="0">
<table width="250" border="0" cellspacing="0" cellpadding="1" bgcolor="#e8e9cb" align="center">
<tr>
<td colspan="2" align="center">
<img src="http://gorgefriends.org/img/gorge_index_02.gif" alt="picture" width="100%" height="50"/>
</td>
</tr>
<tr>
<td colspan="2" align="center" valign="bottom" cellpadding="1">
<font color='#3a493e'size=+2> <b>$[Gorge_Trails/Hike_Name]</b></font>
<tr>
<td colspan="2" align="center" valign="bottom" cellpadding="1">
<font color='#3a493e' size=+1 <b>$[Gorge_Trails/Location], $[Gorge_Trails/State]</b></font>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<img src=$[Gorge_Trails/Picture_URL] alt="picture" width="100%" height="140"/>
</td>
<tr>
<td colspan="2" align="center">
<font color="#999999" size="1">Photo:$[Gorge_Trails/Photo_credit]</font>
</td>
</tr>
<table width="250" border="0" cellspacing="3" cellpadding="0" bgcolor="#e8e9cb" align="center">
<tr><td><b>Trailhead</b></td><td>$[Gorge_Trails/Trailhead]</td></tr>
<tr><td><b>Hike Distance</b></td><td>$[Gorge_Trails/Hike_Dist] miles</td></tr>
<tr><td><b>Difficulty</b></td><td>$[Gorge_Trails/Difficulty]</td></tr>
<tr><td><b>Type</b></td><td>$[Gorge_Trails/Type]</td></tr>
<tr><td><b>Trail Name</b></td><td>$[Gorge_Trails/Trail_name]</td></tr>
<table width="250" border="0" cellspacing="4" cellpadding="0" bgcolor="#e8e9cb" align="center">
<tr><td><font color=#993300>Rails-to-Trails</font color>
</td></tr>
<table width="250" border="0" cellspacing="1" cellpadding="0" bgcolor="#e8e9cb" align="center"> <tr>
<td colspan="2" align="center" valign="bottom">
<font color="#999999" size="1">Copyright: Friends of the Columbia Gorge/Portlandhikers.org is a proud partner of the</font> Gorge Towns to Trails Initiative</font>
</td>
</tr>
</table>]]></text>
<bgColor>ff689a9a</bgColor>
</BalloonStyle>
<ListStyle>
<maxSnippetLines>0</maxSnippetLines>
</ListStyle>
<LineStyle>
<color>ff000080</color>
<width>2</width>
</LineStyle>
</Style>
<StyleMap id="Hikes_style_traillink">
<Pair>
<key>normal</key>
<styleUrl>#Hikes_normal_traillink</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#Hikes_highlight_traillink</styleUrl>
</Pair>
</StyleMap>
<Placemark>
<name>The Dalles Trail</name>
<LookAt>
<longitude>-121.1675204504952</longitude>
<latitude>45.63510133211322</latitude>
<altitude>0</altitude>
<heading>-1.634887800693966e-09</heading>
<tilt>45.00165866539888</tilt>
<range>11801.15617415238</range>
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
</LookAt>
<styleUrl>#Hikes_style_traillink</styleUrl>
<ExtendedData>
<SchemaData schemaUrl="#Trails_Schema_id">
<SimpleData name="Trail_number">4406</SimpleData>
<SimpleData name="Trail_name">The Dalles Trail</SimpleData>
<SimpleData name="Location">Eastern Gorge</SimpleData>
<SimpleData name="Difficulty">Easy</SimpleData>
<SimpleData name="Picture_URL">http://blog.oregonlive.com/terryrichard/2009/05/large_TR.TheDallesTrail.jpg</SimpleData>
<SimpleData name="Link1">http://gorgefriends.org/display.php?modin=51&uid=4921</SimpleData>
<SimpleData name="Link2">http://www.traillink.com/trail/the-dalles-riverfront-trail.aspx#tabPhotoGallery</SimpleData>
<SimpleData name="Photo_credit">Terry Richard/The Oregonian</SimpleData>
<SimpleData name="Hike_Dist">11.2</SimpleData>
<SimpleData name="Trailhead">The Dalles Trailhead</SimpleData>
<SimpleData name="Type">Out and Back</SimpleData>
<SimpleData name="TR_Length">0</SimpleData>
<SimpleData name="Hike_Name">The Dalles Rail Trail</SimpleData>
<SimpleData name="State">Oregon</SimpleData>
<SimpleData name="Elevation1">200 ft.</SimpleData>
<SimpleData name="Hike_Dis_1">miles</SimpleData>
<SimpleData name="POINT_X">-121.197</SimpleData>
<SimpleData name="POINT_Y">45.6276</SimpleData>
</SchemaData>
</ExtendedData>
<gx:balloonVisibility>1</gx:balloonVisibility>
<MultiGeometry>
<LineString>
<tessellate>1</tessellate>
<coordinates>
-121.2191227996079,45.65623491828678,0 -121.2078460984247,45.641231128264,0 -121.2081174642494,45.62199596450162,0 -121.2013742163807,45.61232779014134,0 -121.1763471207253,45.60147362786477,0 -121.1389784963313,45.6012101599156,0 -121.1150449368218,45.61651025155123,0 -121.1141521992769,45.62130724242957,0
</coordinates>
</LineString>
<Point>
<coordinates>-121.197032272514,45.62764529609835,0</coordinates>
</Point>
</MultiGeometry>
</Placemark>
</Document>
</kml>
The anchor spot where the Balloon is positioned on the map is computed as the center point of the geometries in the feature. In the case of the MultiGeometry in your example it is the center of the line and the point combined. The extent of the line is skewing the center to the right.
If you want the balloon anchored at the point then move the LineString to a second feature.
You can hide the fact that you have two features instead of one by adding a ListStyle of type checkHideChildren to the root-level Document to hide the children features like this:
<Document>
<name>KmlFile</name>
<styleUrl>#checkHide</styleUrl>
<Style id="checkHide">
<ListStyle>
<listItemType>checkHideChildren</listItemType>
</ListStyle>
</Style>
...
<Placemark>
<name>The Dalles Trail</name>
<!-- LookAt, ExtendedData, etc. -->
<Point>...</Point>
</Placemark>
<Placemark>
<LineString>...</LineString>
</Placemark>
</Document>

Resources