473,399 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Creating Excel file + inserting values

Hello,

I am trying to archieve the following:

- copy an excel file present on the server
- insert values into named ranges of the copy

I am using Excel97 on my PC, the server does not have
Excel installed on it so I can't create the object
Excel.Application

The server runs Microsoft-IIS/4.0

Although things seem to work, I have a couple of issues:
- when I insert a value into the new copy, the named range
is deleted
- the value is inserted into the worksheet in the cell
BELOW the named cell.
- I don't know how to refer to a cell by its address
instead of a named range.

I am using the following code:
<%

Dim sSourceXLS
Dim sDestXLS

sSourceXLS = Server.MapPath(".") & "\test2.xls"
sDestXLS = Server.MapPath(".") & "\AutoCRF2.xls"

'Copy the source workbook file (the "template") to the
destination filename
Dim fso
Set fso = Server.CreateObject
("Scripting.FileSystemObject")
fso.GetFile(sSourceXLS).Copy sDestXLS
Set fso = Nothing

'Open the ADO connection to the destination Excel
workbook
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sDestXLS & ";" & _
"Extended Properties=""Excel 8.0;HDR=NO;"""
'Add values to individual cells
oConn.Execute "Insert into FirstName Values ('Nancy')"
oConn.Execute "Insert into Surname Values ('Leroy')"
oConn.Execute "Insert into SalaryCode Values
('GM0001')"
oConn.Execute "Insert into DateLastPayed Values
('05/09/2003')"
oConn.Execute "Insert into Address Values ('30/1
Pilrig House Close')"
oConn.Execute "Insert into Telno Values ('0131-
5663452')"
oConn.Close

%>

Does someone know why the cell below the named cell is
updated?
why is the name deleted?
and/or
How to refer to a range by its address instead of its name.

Any help would be greatly appreciated,

Thanks,

kindest regards,

Bertrand
I am using
Jul 19 '05 #1
2 6810
Hi Bertrand,

When using named ranges, you have to name the cell that is above the one
that you want to insert into. Think of the named range as a column header
in a table design or something.

Ray at work
"Bertrand" <be******@bertrandyesyes.com> wrote in message
news:05****************************@phx.gbl...
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sDestXLS & ";" & _
"Extended Properties=""Excel 8.0;HDR=NO;"""

Does someone know why the cell below the named cell is
updated?

Jul 19 '05 #2
I don't know of any way to say like "update [sheet1$] set [f1]='some value'
where ADDRESS='$a$1'"

And it seems that all the ADO samples out there for Excel concentrate mostly
on SELECTS, INSERTs, or UPDATEs that don't specify any range info.

Maybe someone else knows more?

Ray at work

"Bertrand" <df********@sdfgdfgd.cvom> wrote in message
news:02****************************@phx.gbl...
Do you also know if it possible (and if so how) to target
a cell by refering to it by its address instead of its
name?

thanks,

Bertrand

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jeremy Langworthy | last post by:
Hi I am trying to create a MS Excel format CSV but I can't figure out how to get the line feed/carriage return/new record working properly. I am nding each line/record with these characters:...
1
by: Jan Agermose | last post by:
Im writing information into an existing excel document using a connection string like: strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Filename + ";Extended Properties=\"Excel...
0
by: krallabandi | last post by:
Hi, I am trying to generate Excel sheet using Provider=Microsoft.Jet.OLEDB.4.0; I am always getting the error while inserting data into any cell other than A. An unhandled exception of...
7
by: Michael G. Schneider | last post by:
From ASP I create response, which is to be shown as an Excel worksheet in the user's browser (by setting the ContentType and creating a table). This works fine. Does anybody know what to do, if...
1
by: Andre Ranieri | last post by:
I'm having trouble programatically inserting an Excel file into an Image column in our CRM package's SQL 2000 database. The function appears to work ok, but when I attempt to access the file through...
3
by: krallabandi | last post by:
Hi, I am trying to generate Excel sheet using Provider=Microsoft.Jet.OLEDB.4.0; I am always getting the error while inserting data into any cell other than A. An unhandled exception of...
6
by: McKirahan | last post by:
I an using ASP to read a database table and generate an HTML table which is save via FSO with a file extension of .xls which opens up in MS-Excel. I am inserting several lines of text into a cell...
18
by: PW | last post by:
Convert them to CSV in Excel, then use TransferText (which does not work correctly and also doesn't accept XLS/Excel files directly) or create a link to an Excel XLS workbook and do an Append Query...
6
by: dillipkumar | last post by:
hi, i have one excel file, i want to create a hash of hash from the excel file, like: %hash= , sheet2 => , .... .... ];
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
tracyyun
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.