need to import Excel data into Mysql database using coldfusion script. How can i do it. Is there any utility or any script can do it. Thanks in advance.
9 12810
Welcome to TSDN!
You can use the Excel file as a datasource. Loop over the rows and insert them into the database.
What format is the data in?
Welcome to TSDN!
You can use the Excel file as a datasource. Loop over the rows and insert them into the database.
What format is the data in?
The datas are Dotted IP and its corresponding decimal value...And also The sheet included two other columns like country code and country name..
For an Eg:
Dot ip Dec Coucode Couname
19.2.2.2 11111111 Ja Japan
Set up the Excel file as a data source. Use cfquery to get the data and then loop over it as you would with a normal query and insert each row into the MySQL database. If you get stuck, post your code.
How can I make an Email Textbox as a readonly using dojo widget?
How can I make an Email Textbox as a readonly using dojo widget?
That's a different problem. Did you manage to solve the original problem?
copy and past the codes below save it as read.cfm: - <!--- default values --->
-
<cfparam name="form.InputExcelFile" default="">
-
<cfparam name="form.StartCol" default="A">
-
<cfparam name="form.EndCol" default="0">
-
<cfparam name="form.StartRow" default="1">
-
<cfparam name="form.EndRow" default="0">
-
<cfparam name="form.Sheet" default="Sheet1">
-
<cfparam name="form.HeaderRow" default="">
-
<cfparam name="form.Formula" default="process">
-
<cfparam name="form.DecimalDigit" default="2">
-
<cfparam name="form.ProcessMerged" default="true">
-
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-
<html>
-
<head>
-
<title>CFX_Excel Example</title>
-
<style type="text/css">
-
.textfield { font-family: "MS Sans Serif"; font-size: 9pt; border: 1px solid #cccccc; }
-
.button { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bold; color: #FFFFFF; background-color: #000000; cursor: hand}
-
.tablestandard { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }
-
</style>
-
</head>
-
-
<body>
-
<cfoutput>
-
<h3>CFX_Excel Example</h3>
-
<h4>Read Operation - Convert MS Excel File To ColdFusion Query</h4>
-
<hr size=1>
-
<table width="100%" cellpadding="2" cellspacing="2" border="0" class="tablestandard">
-
<cfform action="example_read.cfm" method="POST" enctype="multipart/form-data">
-
<tr>
-
<td nowrap valign="top">Upload Excel file to read:</td>
-
<td width="100%" valign="top">
-
<input type="File" name="InputExcelFile" size="40" class="textfield">
-
</td>
-
</tr>
-
<tr>
-
<td nowrap valign="top">Sheet name or index##:</td>
-
<td width="100%" valign="top">
-
<cfinput type="Text" class="textfield" name="Sheet" value="#form.Sheet#" size="8">
-
</td>
-
</tr>
-
<tr>
-
<td nowrap valign="top">Column to process:</td>
-
<td width="100%" valign="top">
-
Start: <cfinput type="Text" class="textfield" name="StartCol" value="#form.StartCol#" size="8">
-
End: <cfinput type="Text" class="textfield" name="EndCol" value="#form.EndCol#" size="8">
-
(type '0' in the end attribute to process all non-empty/edited columns)
-
</td>
-
</tr>
-
<tr>
-
<td nowrap valign="top">Row to process:</td>
-
<td width="100%" valign="top">
-
Start: <cfinput type="Text" class="textfield" name="StartRow" value="#form.StartRow#" range="1," size="8">
-
End: <cfinput type="Text" class="textfield" name="EndRow" value="#form.EndRow#" size="8">
-
(type '0' in the end attribute to process all non-empty/edited rows)
-
</td>
-
</tr>
-
<tr>
-
<td nowrap valign="top">Header row:</td>
-
<td width="100%" valign="top">
-
<cfinput type="Text" class="textfield" name="HeaderRow" value="#form.HeaderRow#" validate="integer" range="0," size="4"><br>
-
(Row containing column names, if any)
-
</td>
-
</tr>
-
<tr>
-
<td nowrap valign="top">Number of decimal digits:</td>
-
<td width="100%" valign="top">
-
<cfinput type="Text" class="textfield" name="DecimalDigit" value="#form.DecimalDigit#" validate="integer" range="0," size="4">
-
</td>
-
</tr>
-
<tr>
-
<td valign="top">Formula:</td>
-
<td valign="top">
-
<input type="Radio" name="Formula" value="process" #iif(form.Formula is "process",de("checked"),de(""))#>Process<br>
-
<input type="Radio" name="Formula" value="show" #iif(form.Formula is "show",de("checked"),de(""))#>Show<br>
-
</td>
-
</tr>
-
<tr>
-
<td valign="top">Process merged cells:</td>
-
<td valign="top">
-
<input type="Radio" name="ProcessMerged" value="true" #iif(form.ProcessMerged is "true",de("checked"),de(""))#>True<br>
-
<input type="Radio" name="ProcessMerged" value="false" #iif(form.ProcessMerged is "false",de("checked"),de(""))#>False<br>
-
</td>
-
</tr>
-
<tr>
-
<td colspan="2">
-
<input type="Submit" value="Convert Excel To CF Query Now" class="button"><br>
-
<br>
-
<font size="1">
-
<a href="example_write.cfm">Click here to see the CFX_Excel write example</a>
-
</font>
-
</td>
-
</tr>
-
</cfform>
-
</table>
-
-
<cfif form.InputExcelFile neq "">
-
<!--- read operation --->
-
<hr size="1">
-
-
<!--- define temp excel --->
-
<cfset strDir=GetDirectoryFromPath(ExpandPath("*.*")) & "/temp">
-
<cfset strInExcel=strDir>
-
-
<!--- upload image --->
-
<cffile action="Upload"
-
filefield="InputExcelFile"
-
destination="#strInExcel#"
-
nameconflict="MAKEUNIQUE"
-
mode="757">
-
<cfset prodThumbDir=file.ServerDirectory>
-
<cfset prodThumbFile=file.ServerFile>
-
<cfset prodThumbExt=file.serverfileext>
-
<cfif (prodThumbExt neq "xls")>
-
CFX_Excel accepts .xls file only
-
<cfelse>
-
<!--- read excel --->
-
<cftry>
-
<cfset tickBegin = GetTickCount()>
-
<cfx_excel action="read"
-
File="#prodThumbDir#/#prodThumbFile#"
-
Sheet="#form.Sheet#"
-
Result="qryResult"
-
Formula="#form.Formula#"
-
StartRow="#form.StartRow#"
-
EndRow="#form.EndRow#"
-
StartCol="#form.StartCol#"
-
EndCol="#form.EndCol#"
-
HeaderRow="#form.HeaderRow#"
-
ProcessMerged="#form.ProcessMerged#"
-
DecimalDigit="#form.DecimalDigit#">
-
<cfset tickEnd = GetTickCount()>
-
<cfset loopTime = tickEnd - tickBegin>
-
-
<!--- show result query --->
-
<h3>Conversion Result:</h3>
-
<cfdump var="#qryResult#">
-
-
<hr size="2">
-
<h3>Performance</h3>
-
Convert time was: #loopTime# milliseconds<br>
-
Query info: #qryResult.recordcount#<br>
-
<cfif looptime gt 0>
-
Approx. speed: #numberformat(qryResult.recordcount/(looptime/1000))# rows/second
-
</cfif>
-
<br><br>
-
<font size="-1">
-
(Please note that our live example is running in a very busy shared hosting environment)
-
</font>
-
-
<cfcatch type="Any">
-
<h3>There was a problem while reading '#prodThumbFile#'</h3>
-
Check the file, columns to process, rows to process and other properties,<br>
-
to make sure all source cells can be converted to recordset.
-
</cfcatch>
-
</cftry>
-
</cfif>
-
-
<!--- remove temp excel --->
-
<cftry>
-
<cffile action="DELETE" file="#prodThumbDir#/#prodThumbFile#">
-
<cfcatch type="Any"></cfcatch>
-
</cftry>
-
</cfif>
-
</cfoutput>
-
</body>
-
</html>
-
The same with the codes below and save it as viewexcel.cfm: - <cfparam name="url.ExcelFile" default="">
-
<cfif listlast(url.ExcelFile,".") neq "xls">
-
<cfabort>
-
</cfif>
-
<cfset strDir=GetDirectoryFromPath(ExpandPath("*.*"))>
-
<cfif not fileexists("#strDir#temp/#url.ExcelFile#")>
-
<cfabort>
-
</cfif>
-
<cfheader name="Content-Disposition" value="inline; filename=#url.ExcelFile#">
-
<cfcontent type="application/unknown" file="#strDir#temp/#url.ExcelFile#" deletefile="yes">
You can Convert MS Excel File To ColdFusion Query.
copy and past the codes below save it as read.cfm:
... You can Convert MS Excel File To ColdFusion Query.
It makes use of a custom tag to do the job. Did the code contain any copyright information?
It makes use of a custom tag to do the job. Did the code contain any copyright information?
No there is no Copyright. it's on the web for free. I used it befor so I thought it may be hany.
No there is no Copyright. it's on the web for free. I used it befor so I thought it may be hany.
OK, just making sure. Thanks.
It does use cfx_excel which is a custom tag, though. So it wouldn't work 'out of the box'.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Damien |
last post by:
Hi to all,
I need to design an import/export system. Data comes from a filemaker
pro DB in a big CSV file. Some alterations are made on the data as it is
imported into my mysql table. Data is...
|
by: Phil Perrin |
last post by:
------=_NextPart_000_0001_01C3663D.5E3EAD70
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
I'm a relative newbie to MySql, and I've got a small project I'm working...
|
by: Johnny |
last post by:
I was looking for information on how to import an excel file or other
text file into a MySql database. I have done this with both access
and SQL Server and am looking for a way to do this in...
|
by: dimitri |
last post by:
i try to copy data from excel into my MySql database which runs on a
linux.
i use MS Access to access the database. i need to optain the unique id
number, and this is where i have some troubles....
|
by: fkulaga |
last post by:
Hi all,
I have a problem with the issue in the subject, i have all data in one
big excel file,
in a denormalized form, and on the other side, i have mysql database
with many tables, which is...
|
by: nehashri |
last post by:
hello
i have my data stored in different Ms Excell sheets. now I am planning to make a database of the data i have. but i m confused whether to use Postgresql or mySQL for the same. i had plans to...
|
by: vj83 |
last post by:
Hi,
I have a C#.net application in which i have read the datas from excel sheet and displayed in a datagrid in my Aspx form.
The code is here
private void Button2_Click(object sender,...
|
by: kelvenng |
last post by:
Hi all hope some one can help me solve my problem.
Actually I want import data from excel to my MYSQL server by using VB6
I facing the problem on my coding and system show me the error.
below is...
|
by: arshigill |
last post by:
I want to import data from excel file inot mysql database table but unable to solve this problem.
I have searched google and find an example of importing of CSV excel file.
But when I modify it...
|
by: thesti |
last post by:
hello,
how to programmatically from VB .net / php. to import data from an EXCEL file?
is there's no programmatic way, how to automated the process. as i search, the process is:
Simply...
|
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: 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...
|
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: 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...
|
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...
| |