ColdFusion Exporting to Excel - coldfusion

I have a Excel filte that was exported from ColdFusion data. My question is do we have an option to move U & V column cells to the left of column B using ColdFusion. Here my code below :
<cfheader name="Content-Disposition" value="attachment; filename=Reporting.xls">
<cfcontent type="application/vnd.ms-excel">
<table cellspacing="1" border="0">
<thead>
<tr>
<th colspan="3" style="border-style:none;"> </th>
<th class="cellSpacer"> </th>
<th colspan="7" class="colorHeader">Major Maintenance Expenditure ($k)</th>
<th class="cellSpacer"> </th>
<th colspan="7" class="colorHeader">Capital Expenditure ($k)</th>
<th class="cellSpacer"> </th>
<th colspan="7" class="colorHeader">Asset Retirement Obligations ($k)</th>
<th class="cellSpacer"> </th>
<th colspan="7" class="colorHeader">Environmental Liability ($k)</th>
<th class="cellSpacer"> </th>
</tr>
<cfoutput query="Myqry">
<tr>
<td>#Myquery.columns1#</td>
</tr>
</cfoutput>
</table>

I recommend looking into <cfspreadsheet> https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-r-s/cfspreadsheet.html

Related

Show a List of value vertically in jsp page

<table class="table">
<thead>
<tr>
<th scope="col">Book Id</th>
<th scope="col">Book Name</th>
<th scope="col">Book Author</th>
</tr>
</thead>
<tbody>
<tr>
<td><c:forEach items="${searchedBook}" var="book">
${book.book_id}
</c:forEach></td>
</tr>
<tr>
<td><c:forEach items="${searchedBook}" var="book">
${book.book_name}
</c:forEach></td>
</tr>
<tr>
<td><c:forEach items="${searchedBook}" var="book">
${book.book_author}
</c:forEach></td>
</tr>
</tbody>
</table>
how the table looks like now
but how I want it is like this,
the way I want it to look like
Is there a way to make it possible?
You declare forEach loop inside <td> tag it print all data in single <td>
Here down modified code:
<table class="table">
<thead>
<tr>
<th scope="col">Book Id</th>
<th scope="col">Book Name</th>
<th scope="col">Book Author</th>
</tr>
</thead>
<tbody>
<tr>
<c:forEach items="${searchedBook}" var="book">
<td>${book.book_id}</td>
</c:forEach>
</tr>
<tr>
<c:forEach items="${searchedBook}" var="book">
<td>${book.book_name}</td>
</c:forEach>
</tr>
<tr>
<c:forEach items="${searchedBook}" var="book">
<td>${book.book_author}</td>
</c:forEach>
</tr>
</tbody>
</table>

Sublist in Netsuite PDF/HTML Template

I have a credit memo template for which I want to include what invoices this credit has been applied to (This information is in a sublist on the record under ITEM > Apply )
I currently have the below code in the template, which only seems to show the first invoice in the sublist?? I can't figure why.
<#if record.apply?has_content>
<table>
<thead><tr><th>Applied to:</th></tr></thead></table>
<table><#list record.apply as apply><#if apply_index==3>
<thead>
<tr>
<th style="align: center;">Date</th>
<th style="align: center;">Invoice</th>
<th style="align: center;">Original Amount</th>
<th style="align: center;">Payment</th>
<th style="align: center;">Due</th>
</tr>
</thead><tr>
<td style="align: center;">${apply.duedate}</td>
<td style="align: center;">${apply.refnum}</td>
<td style="align: center;">${apply.total}</td>
<td style="align: center;">${apply.amount}</td>
<td style="align: center;"><#assign remaining=(apply.total)-(apply.amount)>${remaining?string.currency}</td>
</tr></#if></#list>
</table></#if>
I don't have access to any suitescript or serverscript or anything like that, so I need a solution to the source code in the PDF/HTML Template (if possible)
You have <#if apply_index==3>, this is only ever true once. It should be <#if apply_index==0> and that should end after defining the thead.
The rest of the list loop should be as is. The problem is your if statement. It's typically used to only create the header at index 0. The rest of the tbody is produced outside of the if statement and inside the list loop.
Since your header is 100% static typed, you do not need the if statement at all. You should only have the TR sections within the TBODY within your list loop.
<#if record.apply?has_content>
<table>
<thead><tr><th>Applied to:</th></tr></thead></table>
<table>
<thead>
<tr>
<th style="align: center;">Date</th>
<th style="align: center;">Invoice</th>
<th style="align: center;">Original Amount</th>
<th style="align: center;">Payment</th>
<th style="align: center;">Due</th>
</tr>
</thead>
<tbody>
<#list record.apply as apply>
<tr>
<td style="align: center;">${apply.duedate}</td>
<td style="align: center;">${apply.refnum}</td>
<td style="align: center;">${apply.total}</td>
<td style="align: center;">${apply.amount}</td>
<td style="align: center;"><#assign remaining=(apply.total)-(apply.amount)>${remaining?string.currency}</td>
</tr>
</#list>
</tbody>
</table>
</#if>

DAX - filtering out whole row from data table that meets certain condition(s)

I have a table like following:
<style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
.tg .tg-baqh{text-align:center;vertical-align:top}
</style>
<table class="tg">
<tr>
<th class="tg-baqh">Store Name</th>
<th class="tg-baqh">Week Number</th>
<th class="tg-baqh">Sales</th>
<th class="tg-baqh">Sales-LY</th>
</tr>
<tr>
<td class="tg-baqh">Store A</td>
<td class="tg-baqh">1</td>
<td class="tg-baqh">20</td>
<td class="tg-baqh">15</td>
</tr>
<tr>
<td class="tg-baqh">Store A</td>
<td class="tg-baqh">2</td>
<td class="tg-baqh">25</td>
<td class="tg-baqh">20</td>
</tr>
<tr>
<td class="tg-baqh">Store A</td>
<td class="tg-baqh">3</td>
<td class="tg-baqh">30</td>
<td class="tg-baqh">25</td>
</tr>
<tr>
<td class="tg-baqh">Store B</td>
<td class="tg-baqh">1</td>
<td class="tg-baqh">15</td>
<td class="tg-baqh">10</td>
</tr>
<tr>
<td class="tg-baqh">Store B</td>
<td class="tg-baqh">2</td>
<td class="tg-baqh">15</td>
<td class="tg-baqh">15</td>
</tr>
<tr>
<td class="tg-baqh">Store B</td>
<td class="tg-baqh">3</td>
<td class="tg-baqh">20</td>
<td class="tg-baqh">15</td>
</tr>
<tr>
<td class="tg-baqh">Store C</td>
<td class="tg-baqh">1</td>
<td class="tg-baqh">30</td>
<td class="tg-baqh">25</td>
</tr>
<tr>
<td class="tg-baqh">Store C</td>
<td class="tg-baqh">2</td>
<td class="tg-baqh">0</td>
<td class="tg-baqh">20</td>
</tr>
<tr>
<td class="tg-baqh">Store C</td>
<td class="tg-baqh">3</td>
<td class="tg-baqh">25</td>
<td class="tg-baqh">20</td>
</tr>
</table>
I would like to return (lets' say) a pivot table with
Salex IDX = SUM(Sales)/SUM(Sales-LY) as a measure, ignoring the data points for "Week 2 for Store C".
So it's not a filter on just Week Number or Store, but its a filter on specific row(s) identified by multiple parameters.
Essentially, i would like to get 'like for like' results, excluding any weeks where Sales or Sales-LY columns are zero(or null)
Any ideas?
I would add a calculated column to concatenate Store and Week, something like this:
=[Store Name]&", Week: "&[Week Number]
Then you can use a filter or slicer to exclude the Store & Week combination you want.

screen scraping using coldfusion

I am trying to screen scrape another application using the below code in Coldfusion.
<cfhttp url="https://intra.att.com/itscmetrics/EM2/LTMR.cfm" method="get" username="uvwxyz" password="abcdef">
<cfhttpparam type="url" name="LTMX" value="Andre Fuetsch / Shelly K Lazzaro">
</cfhttp>
<cfset myDocument = cfhttp.fileContent>
<cfoutput>
#myDocument#
</cfoutput>
Now when I run my cfm page, iam able to access the desitination page, with the above code.
The destination page looks like below.
A part of the source code of this is as below.
<table border="1" width=99% style="border-collapse:collapse;">
<thead>
<td colspan="12" class="drpmainheader1_2">LTM Detail Report for Andre Fuetsch / Shelly K Lazzaro</td>
<tr align="center">
<th class="ptitles">Liaison Name</th>
<th class="ptitles">Application Acronym</th>
<th class="ptitles">MOTS ID</th>
<th class="ptitles">Priority</th>
<th class="ptitles">MC</th>
<th class="ptitles">DR Exercise</th>
<th class="ptitles">ARM/SRM Maintenance</th>
<th class="ptitles">ARM/SRM Creation</th>
<th class="ptitles">Backup & Recovery Certification</th>
<th class="ptitles">Interface Certification</th>
<th class="ptitles">AIA Compliance</th>
</tr>
</thead>
<tbody>
<tr>
<td class="drpdetailtablerowdetailleft">Lynette M Acosta</td>
<td class="drpdetailtablerowdetailleft">AABA</td>
<td class="drpdetailtablerowdetail">9710</td>
<td class="drpdetailtablerowdetail">5</td>
<td class="drpdetailtablerowdetail">NMC</td>
<td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="drpdetailtablerowdetailleft">Lynette M Acosta</td>
<td class="drpdetailtablerowdetailleft">ABS RECON+</td>
<td class="drpdetailtablerowdetail">13999</td>
<td class="drpdetailtablerowdetail">3</td>
<td class="drpdetailtablerowdetail">NMC</td>
<td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td>
</tr>
</tbody>
I am not good with regex in coldfusion, Can anyone please guide me or give me any starting points as to how to extract the data from the html table using Coldfusion? I do not have access to the DB. Hope this is clear.
Parsing HTML using regex? You'll have more options if you use the jsoup HTML Parser w/ColdFusion. Jsoup uses jQuery-like DOM selectors and can quickly convert the HTML table data into arrays.
http://jsoup.org/
Here are some related articles & sample code:
http://www.raymondcamden.com/index.cfm/2012/4/6/jsoup-adds-jQuerylike-parsing-in-Java
http://www.bennadel.com/blog/2358-Parsing-Traversing-And-Mutating-HTML-With-ColdFusion-And-jSoup.htm
http://pastebin.com/U6A86mSi

Linux (sed|PCRE|grep) Regular expression to isoloate XML (KML) style data conditionally

Updates after sample code.
Solution: as provided by BeniBela He figured out what I failed to make clear...It has to be command line, not necessarily regex, and offered up this solution:
xpath -e '//Placemark[contains(description, "Iron")]'
as promised:
|
( )
/ \
_______
| _ |
| | | | All must enter and pay homage! (Shrine of BeniBela)
Problem: I need some form of command line regex to accomplish the following: Detect in one file of a set of Placemarks, Placemarks which include a keyword (in this case Iron) in a contained CDATA tag. without grabbing Placemarks which do not have the keywod. (All data from <Placemark> to </Placemark> needs to be captured.)
Explanation:
Two code samples are given below, one showing three full placemarks, two of which are useless to me, the third of which I want. The second code sample shows just the one I am interested in.
I need to extract the valid Placemark from the data file (which contains hundreds of placemarks) and append it into another file. I will then merge this file into a properly formatted KML later. The data sets are from the US Geological Survey and are very large.
The idea here is to recover placemarks for mines which are extracting a given kind of Ore (Iron for this example), and create a specialized KML (Keyhole Markup Language) file for display in a Google Earth type application.
sample1 (Multiple data with one valid entry):
<Placemark>
<name>
Las Antos Prospect</name>
<Snippet>
Record 10005251</Snippet>
<description>
<![CDATA[<p>
Record <a href="http://mrdata.usgs.gov/mrds/show.php?labno=10005251">
10005251</a>
of the <a href="http://mrdata.usgs.gov/mrds/">
Mineral Resources Data System</a>
</p>
<table border='1' padding='3' cellspacing='0'>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
oper_type</th>
<td>
Unknown</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
dev_stat</th>
<td>
Occurrence</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
ore</th>
<td>
Limestone</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
model</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod1</th>
<td>
Limestone, General</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod2</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod3</th>
<td>
</td>
</tr>
</table>
]]>
</description>
<styleUrl>
#defaultStyleMap</styleUrl>
<Point>
<altitudeMode>
relativeToGround</altitudeMode>
<coordinates>
-64.88273,-24.87527,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>
Unnamed Occurence</name>
<Snippet>
Record 10005252</Snippet>
<description>
<![CDATA[<p>
Record <a href="http://mrdata.usgs.gov/mrds/show.php?labno=10005252">
10005252</a>
of the <a href="http://mrdata.usgs.gov/mrds/">
Mineral Resources Data System</a>
</p>
<table border='1' padding='3' cellspacing='0'>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
oper_type</th>
<td>
Unknown</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
dev_stat</th>
<td>
Occurrence</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
ore</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
model</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod1</th>
<td>
Iron</td> ######################Iron here makes it valid
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod2</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod3</th>
<td>
</td>
</tr>
</table>
]]>
</description>
<styleUrl>
#defaultStyleMap</styleUrl>
<Point>
<altitudeMode>
relativeToGround</altitudeMode>
<coordinates>
-64.81607,-24.67527,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>
Merced I Quarry</name>
<Snippet>
Record 10005254</Snippet>
<description>
<![CDATA[<p>
Record <a href="http://mrdata.usgs.gov/mrds/show.php?labno=10005254">
10005254</a>
of the <a href="http://mrdata.usgs.gov/mrds/">
Mineral Resources Data System</a>
</p>
<table border='1' padding='3' cellspacing='0'>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
oper_type</th>
<td>
Unknown</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
dev_stat</th>
<td>
Producer</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
ore</th>
<td>
Limestone</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
model</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod1</th>
<td>
Limestone, General</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod2</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod3</th>
<td>
</td>
</tr>
</table>
]]>
</description>
<styleUrl>
#ProducerStyleMap</styleUrl>
<Point>
<altitudeMode>
relativeToGround</altitudeMode>
<coordinates>
-65.46052,-24.9586,0</coordinates>
</Point>
</Placemark>
The above sample contains two Placemarks which I have no use for, bracketing one which I need to extract.
Sample 2 (Showing just a 'valid' entry):
(The capture would need to grab all of this)
<Placemark>
<name>
Unnamed Occurence</name>
<Snippet>
Record 10005252</Snippet>
<description>
<![CDATA[<p>
Record <a href="http://mrdata.usgs.gov/mrds/show.php?labno=10005252">
10005252</a>
of the <a href="http://mrdata.usgs.gov/mrds/">
Mineral Resources Data System</a>
</p>
<table border='1' padding='3' cellspacing='0'>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
oper_type</th>
<td>
Unknown</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
dev_stat</th>
<td>
Occurrence</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
ore</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
model</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod1</th>
<td>
Iron</td> ######################Iron here makes it valid
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod2</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod3</th>
<td>
</td>
</tr>
</table>
]]>
</description>
<styleUrl>
#defaultStyleMap</styleUrl>
<Point>
<altitudeMode>
relativeToGround</altitudeMode>
<coordinates>
-64.81607,-24.67527,0</coordinates>
</Point>
</Placemark>
Update 1:
I got this to work in a regex tester, but I am still working on how to get it into grep et.al.
<Placemark>\n<name>\n.*</name>\n<Snippet>\n.*\n<description>\n(?:(?:.*\n){48}.*Iron.*\n|(?:.*\n){41}.*Iron.*\n|(?:.*\n){35}.*Iron.*\n)(?:.*\n){3,16}\]\]>\n</description>\n(?:.*\n){8,12}</Placemark>
That is trivial with XPath instead regex:
/Placemark[contains(description, "Iron")]
(or /*/Placemark[contains(description, "Iron")] if your xml contains a (required) root element)