473,585 Members | 2,512 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Applicati on

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.CreateOb ject
("Scripting.Fil eSystemObject")
fso.GetFile(sSo urceXLS).Copy sDestXLS
Set fso = Nothing

'Open the ADO connection to the destination Excel
workbook
Set oConn = Server.CreateOb ject("ADODB.Con nection")
oConn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & sDestXLS & ";" & _
"Extended Properties=""Ex cel 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 6817
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******@bertr andyesyes.com> wrote in message
news:05******** *************** *****@phx.gbl.. .
Set oConn = Server.CreateOb ject("ADODB.Con nection")
oConn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & sDestXLS & ";" & _
"Extended Properties=""Ex cel 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********@sdf gdfgd.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
7011
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: "\r\n" but the Excel file just loads all the field in one row as if it doesn't recognise these characters. These are the headers I am using to...
1
10618
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 8.0;HDR=yes;\""; and one of to methods for inserting data. First I simply tried building insert statements as strings "insert into (, ) values...
0
1180
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 type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
7
1951
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 one of the cells should contain a multiline text? I already tried by inserting a <br> inside the <td>. But this won't work. -- Michael G....
1
13260
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 the application's front end the file appears to be corrupt. The front-end application has a way of inserting files to the column, however when I...
3
5019
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 type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
6
24536
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 and would like to force a line break between them. I recorded an MS-Excel macro so see how Alt-Enter was captured which turned out to be Chr(10)...
18
2550
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 (as some have suggested here)?? I find that hard to believe as Access is part of MS Office and Visual FoxPro is not. I split my time using both...
6
6021
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
7908
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8199
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8336
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6606
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.