I'm using the following function (I'm displaying the guts of it only) to
convert a datatable to an excel spreadsheet:
For Each mrow In dt.Rows
rowindex += 1
colindex = 0
For Each col In dt.Columns
colindex += 1
objws.Cells(rowindex, colindex) = mrow(col.ColumnName).ToString()
Next
Next
This works fine, but if there's a string which looks like a number, prefix
'0's are dropped - eg, '07' become '7'. Is there any way to avoid this and
have the .xls file display '07'?
Thanks for any help.
Bernie Yaeger 2 1068
Hi Bernie,
You should add a ' as the first char of the values you
pass to Excel, it then will be seen as a string.
OTH
Patrick Penet
"Bernie Yaeger" <be*****@cherwellinc.com> a écrit dans le message de news:eN****************@TK2MSFTNGP12.phx.gbl... I'm using the following function (I'm displaying the guts of it only) to convert a datatable to an excel spreadsheet:
For Each mrow In dt.Rows rowindex += 1 colindex = 0 For Each col In dt.Columns colindex += 1 objws.Cells(rowindex, colindex) = mrow(col.ColumnName).ToString() Next Next
This works fine, but if there's a string which looks like a number, prefix '0's are dropped - eg, '07' become '7'. Is there any way to avoid this and have the .xls file display '07'?
Thanks for any help.
Bernie Yaeger
Hi Patrick,
I got this answer somewhat earlier on an Excel newsgroup, and it works fine.
Thanks very much!
Bernie
"Patrick Penet" <ph***********@club-internet.fr> wrote in message
news:40**********************@news.club-internet.fr... Hi Bernie, You should add a ' as the first char of the values you pass to Excel, it then will be seen as a string. OTH Patrick Penet
"Bernie Yaeger" <be*****@cherwellinc.com> a écrit dans le message de
news:eN****************@TK2MSFTNGP12.phx.gbl... I'm using the following function (I'm displaying the guts of it only) to convert a datatable to an excel spreadsheet:
For Each mrow In dt.Rows rowindex += 1 colindex = 0 For Each col In dt.Columns colindex += 1 objws.Cells(rowindex, colindex) = mrow(col.ColumnName).ToString() Next Next
This works fine, but if there's a string which looks like a number,
prefix '0's are dropped - eg, '07' become '7'. Is there any way to avoid this
and have the .xls file display '07'?
Thanks for any help.
Bernie Yaeger
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sakitah |
last post by:
Hello Everyone,
Here's the problem: I have a string that I break down into 3 other
strings as such:
string1 = "001-202-1234567"
and parsing it into:
string2 = "001";
|
by: samik_tanik |
last post by:
I need to export a datagrid to Excel.
I could did this. But, also need to keep the leading
zeros in the data.
How can I acheive this?
Any help would be appreciated.
--
Thanking you in...
|
by: Bernie Yaeger |
last post by:
I use the following writexml method to convert a dataset/datatable to .xml:
ds.WriteXml(mstrpath, XmlWriteMode.WriteSchema)
ds.WriteXmlSchema(mstrpathxsd)
The path strings are simple full...
|
by: zexpe |
last post by:
I have an extremely cpu/data intensive piece of code that makes heavy
use of the following function:
void convertToDouble(const std::string& in, double& out)
{
out = atof(in.c_str());
}
I...
|
by: UKuser |
last post by:
Hi Guys,
I have a program which converts Excel spreadsheets to Javascript and
allows interactivity. However it can't convert it to PHP, which is
obviously better for users to view (in case J/S...
|
by: Testguy |
last post by:
Hi,
I was wondering if one the smart people that frequent this group could
give me a hand with a small program I am attempting to debug.
I am not a highly experienced developer, but can...
|
by: simchajoy2000 |
last post by:
Hi,
So I do actually know how to read excel into VB.NET using the following
approach:
With oConn2
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source="
& FilePath & ";Extended...
|
by: CoreyWhite |
last post by:
Problem:
You have numbers in string format, but you need to convert them to a
numeric type, such as an int or float.
Solution:
You can do this with the standard library functions. The...
|
by: MM |
last post by:
Hi to all,
I'm trying to import a tab separated values file onto Excel with the
following script:
import csv
from pyExcelerator import *
w = Workbook()
worksheet = w.add_sheet('sim1')
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |