[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

opening datagrid to Excel - Excel is changing the format of a column to a number from a string

I have a datagrid that has a column which is a string identity field that is 19 characters long - all the characters values are numeric.  I'm exporting and opening the datagrid in Excel using a xslt file.  Excel changes the values from string to numeric and the result is a number who's last character is incorrect and and displays in scientific notation.

Datagrid Column Value: 4003000000009010001
What I see in the resulting worksheet in Excel: 4.003E+18
What i see in the data field at the top: 4003000000009010000

The line in the xslt file

<TD>
<xsl:value-of select="IDNUMBER" />
</TD>


How can I tell Excel not to convert this data?
0
CaseyRobertsTTU
Asked:
CaseyRobertsTTU
  • 4
  • 3
1 Solution
 
ctm5Commented:
Prepend the number with an apostrophe.

ctm5
0
 
CaseyRobertsTTUAuthor Commented:
Thanks for the suggestion. I can't have an apostrophe showing up in the final spreadsheet.  I need a way to tell Excel, through code, not to convert the string to a number.  I was hoping to be able to specify an attribute in the xslt line.
0
 
ctm5Commented:
You could try setting the numberformat of the column to "@" (in VB code).
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
CaseyRobertsTTUAuthor Commented:
It's not a number in my datagrid column.  It's a string value being written in XML to be opened by Excel.  Excel, based on the fact that all the characters are numbers, changes it for me.  I have no control of the users Excel program, just the file I'm creating.  I'd like to know how to explicitly declare a field as a string in XML or in the XSLT - without adding string characters to my data.

XML line is: <IDNUMBER>4003000000009010001</IDNUMBER>
0
 
ctm5Commented:
Right, you have control of the file you are creating. Which is an Excel spreadsheet, right? So you can figure out (in code) what column it is that is a problem and set its format to "@" This is done in the VB code (which I assume you must resort to at some point, since you have posted this in the VB.NET forum). If you want to do it in XML or XSLT, you might try a different forum. (In your original question, you did not specify a solution must lie in the XML or XSLT.)

ctm5
0
 
CaseyRobertsTTUAuthor Commented:
Sorry, for the confusion.  I'm not writing an Excel file (.xls). The VB.Net program is taking the data from my datagrid columns and writing an XML file to be opened by Excel.  In the XML file the data is correct.  I need a way to write the XML file in such a way that Excel doesn't reformat the data when it opens it.

I have added this question to the XML area, but no response there yet.  

Thanks for your suggestions so far.  
0
 
CaseyRobertsTTUAuthor Commented:
I decided to use the apostrophe as a temporary solution until I can find the answer I need.  Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now