Converting Excel spreadsheet to XML - excel

I have an excel spreadsheet. When I tried to save the Excel spreadsheet as XML, all the leading zeros are lost. I am using Excel 2016. I have 63138 rows in excel spreadsheet. Below is the sample data of my excel spreadsheet.
Col1 col2 col3 col4 col5
32 000001 000 001 1
32 000032 000 032 22
32 000111 000 111 032
How can I prevent excel to drop off the leading zeros when I save the file as XML. All the last columns have been formatted as text. Below is the image:
Any help will be appreciated.

You can use XlRangeValueDataType enumeration for the Value property of Range object. All zeros are preserved. For your example with five columns you will get:
Sub GGG()
Dim rng As Range
Dim xml$
xml = Range("A1").CurrentRegion.Value(XlRangeValueDataType.xlRangeValueXMLSpreadsheet)
'// Save string here somewhere
End Sub
Output:
<?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">
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Calibri" x:CharSet="204" x:Family="Swiss" ss:Size="11"
ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s63">
<Alignment ss:Horizontal="Left" ss:Vertical="Center"/>
<Font ss:FontName="Inherit" x:CharSet="204" ss:Color="#303336"/>
</Style>
<Style ss:ID="s68">
<NumberFormat ss:Format="#"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="5" ss:ExpandedRowCount="4" ss:StyleID="s68"
ss:DefaultRowHeight="15">
<Row>
<Cell ss:StyleID="s63"><Data ss:Type="String">Col1</Data></Cell>
<Cell><Data ss:Type="String">col2</Data></Cell>
<Cell><Data ss:Type="String">col3</Data></Cell>
<Cell><Data ss:Type="String">col4</Data></Cell>
<Cell><Data ss:Type="String">col5</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">32</Data></Cell>
<Cell><Data ss:Type="String">000001</Data></Cell>
<Cell><Data ss:Type="String">000</Data></Cell>
<Cell><Data ss:Type="String">001</Data></Cell>
<Cell><Data ss:Type="String">1</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">32</Data></Cell>
<Cell><Data ss:Type="String">000032</Data></Cell>
<Cell><Data ss:Type="String">000</Data></Cell>
<Cell><Data ss:Type="String">032</Data></Cell>
<Cell><Data ss:Type="String">22</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">32</Data></Cell>
<Cell><Data ss:Type="String">000111</Data></Cell>
<Cell><Data ss:Type="String">000</Data></Cell>
<Cell><Data ss:Type="String">111</Data></Cell>
<Cell><Data ss:Type="String">032</Data></Cell>
</Row>
</Table>
</Worksheet>
</Workbook>

Related

Add Custom Record Type Sublist in NetSuite Advanced PDF/HTML Template

I am trying to add a custom record type sublist on a Bill of Materials Advanced PDF template.
I copied the code format for item table and change it with the id of the custom record type. I was able to save the PDF template without error. However, only the standard Items sublist are showing, and my custom record sublist is not showing on the printed PDF.
Here are the ids of the custom record type and its fields applied to the work order transaction.
I have also set the custom record type to be a child record of the work order parent transaction.
Custom Record Type: Solvent Add Back (id=customrecord_solvent_add_back)
Fields:
Solvent Add Back Parent [List/Record=Transaction, Record is Parent=YES] (custrecord_solvent_add_back_parent)
Solvent Item (custrecord_solvent_item)
Solvent Quantity (custrecord_solvent_quantity)
Unit (custrecord162)
Solvent Batch Number (custrecord_solvent_batch_number)
<#if record.custrecord_solvent_add_back_parent?has_content>
<table style="width: 100%; margin-top: 10px;">
<thead>
<tr>
<th colspan="5" style="font-size:14px;">Solvent Item</th>
<th align="right" colspan="3" style="font-size:14px;">Qty.</th>
<th align="right" colspan="3" style="font-size:14px;">Unit</th>
<th align="right" style="width: 143px;font-size: 14px;">Batch Number</th>
</tr>
</thead>
<#list record.custrecord_solvent_add_back_parent as item>
<tr>
<td colspan="5" style="font-size:14px;">${item.custrecord_solvent_item}</td>
<td align="right" colspan="3" style="font-size:14px;">${item.custrecord_solvent_quantity}</td>
<td align="right" colspan="3" style="font-size:14px;">${item.custrecord162}</td>
<td align="right" style="width: 143px;font-size: 14px;">${item.custrecord_solvent_batch_number}</td>
</tr>
</#list></table></#if>
I am fairly new to Advanced PDF/HTML source code editing product area with less than 2 months of experience. But has more than 4 years of NetSuite experience.
Thanks in advance for all your help.
As far as i know, its not possible to have child record/custom record data in Advanced PDF. Better go with a suitelet.

Consolidation of Data using certain keys in XSLT

I have an input XML file:
<root>
<row>
<col1>cust001</col1>
<col2>cc1</col2>
<col3>po1</col3>
<col4>2020-02-22</col4>
<col5>Men</col5>
<col6>item1</col6>
<col7>60</col7>
</row>
<row>
<col1>cust001</col1>
<col2>cc1</col2>
<col3>po1</col3>
<col4>2020-02-22</col4>
<col5>Men</col5>
<col6>item2</col6>
<col7>50</col7>
</row>
</root>
Desired output: (if col1 to col5 are the same, consolidate into one row.)
<root>
<row>
<col1>cust001</col1>
<col2>cc1</col2>
<col3>po1</col3>
<col4>2020-02-22</col4>
<col5>Men</col5>
<col6>item1</col6>
<col7>60</col7>
<col6>item2</col6>
<col7>50</col7>
</row>
</root>
I'm trying the code here XSLT Consolidating data when ID is the same but I'm getting, Error in Expression current-group(): Unknown system function: current group.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.castiron.com//response">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="resultSets">
<xsl:apply-templates select="#*|node()"/>
</xsl:template>
<xsl:template match="resultSet">
<xsl:apply-templates select="#*"/>
<xsl:for-each-group select="root/row" group-by="concat(col1,col2,col3,col4,col5)">
<xsl:value-of select="current-grouping-key()"/>
<xsl:apply-templates select="current-group()" />
</xsl:for-each-group>
</xsl:template>
Assuming you use an XSLT 3 processor like Saxon 9.8 or later or AltovaXML 2017 R3 or later you can use a composite grouping key of the elements you want to use as a grouping key, then, inside, you of course need to make sure you create a single row for each group and only process the items forming the grouping key once (e.g. for the first item in the group which is the context item inside of the for-each-group) and then all the other elements for all items in the group:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
version="3.0">
<xsl:output indent="yes"/>
<xsl:mode on-no-match="shallow-copy"/>
<xsl:template match="root">
<xsl:copy>
<xsl:for-each-group select="row" composite="yes" group-by="col1, col2, col3, col4, col5">
<xsl:copy>
<xsl:apply-templates select="col1, col2, col3, col4, col5, current-group()/(* except (col1, col2, col3, col4, col5))"/>
</xsl:copy>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
https://xsltfiddle.liberty-development.net/jz1Q1yt
Or, perhaps, the body of the for-each-group is a bit less repetitive in terms of the grouping key elements with
<xsl:template match="root">
<xsl:copy>
<xsl:for-each-group select="row!copy-of()" composite="yes" group-by="col1, col2, col3, col4, col5">
<xsl:copy>
<xsl:apply-templates select="current-group()/(if (position() eq 1) then * else (* except (col1, col2, col3, col4, col5)))"/>
</xsl:copy>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
https://xsltfiddle.liberty-development.net/jz1Q1yt/1

Get html data in post method in netsuite suitelet

I have a suitelet in which in run html code having an html table. I have given checkbox to the table. I wanted to retrieve number of lines and values in table which are checked after I click Submit on Suitelet. However, I only get one value of checkbox and not how many lines I have set the checkbox true.
<table>
<tbody>
<tr>
<td>
<input type="checkbox" class="select-items" name="selectitem" id="selectitem">
</td>
</tr>
<tbody>
<table>

Create a table grid using a single repeat control in xpages

I would like to create a table with 4 columns and 4 or more rows (so 16 or more items per page) using a single repeat control. Is this possible at all? I have achieved the desired affect in the past using div tags and display in-line, but would like to know whether it's possible to achieve this using a table. When the code is generated by a repeat control, how could I tell it to create a new row when it reaches the 4th element?? Any ideas at all?
The repeat control has facets for the header and footer that you can use to output the html tags required for the table header and footer like this...
<xp:this.facets>
<xp:text disableTheme="true" xp:key="header" escape="false">
<xp:this.value><![CDATA[
<table>
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
</tr>
</thead>
<tbody>]]></xp:this.value>
</xp:text>
<xp:text disableTheme="true" xp:key="footer" escape="false">
<xp:this.value><![CDATA[
</tbody>
</table>]]></xp:this.value>
</xp:text>
</xp:this.facets>
Then inside your repeat control you could repeat a single computed field which will output the html and cell contents for the table. use the Repeat Index variable to determine if the computed field control should include the <tr> or </tr> tags and make sure the control has been set to display contents as html.

SharePoint 2010 Populate Lookup Field on Activation

I have two lists: [Parents] [Children]. The Children list has a one-to-one lookup column to the Parents list. When deploying the Children List I have data written into the tag using
<Data>
<Rows>
<Row>
<Field Name="ChildName">Stephanie</Field>
<Field Name="ParentNameLookup">What value goes here?</Field>
</Row>
</Rows>
</Data>
My question: is there a way to populate the data into the tag for the ParentNameLookup field?
Try this
<Field Name="ParentNameLookup">ID;#VALUE</Field>
Where ID is ID of the Parent List Item and VALUE Represents actual Text.

Resources