从Excel读取数据 [英] Reading the data from Excel

查看:78
本文介绍了从Excel读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库并创建了一个表。

我有一张excel表,其中包含数据。我需要将数据从excel导出到我的数据库。我正在使用SQL Server Management Studio 2012.我为此编写了一个java代码。我只有一个疑问。如何读取excel中的值并导出到SQL?我编写了代码,但它抛出了Unclosed String Literal和Not a statement错误。能否请你帮忙 ?在此先感谢。



pstm = con.prepareStatement(sql);

字符串A = row.getCell(0).getStringCellValue() ;

String B = row.getCell(1).getStringCellValue();

String C = row.getCell(2).getStringCellValue();

String D = row.getCell(3).getStringCellValue();

String sql =INSERT INTO tablename+VALUES('+ A +',

'+ B +',

'+ C +',

'+ D +');





你能告诉我这是什么错误吗?

解决方案

看看这个:读取Excel值并存储到数据库 [ ^ ]

I have a database and created a table.
I have an excel sheet where the data is present. I need to export the data from excel to my database. I am using SQL Server Management Studio 2012. I have written a java code for this. I just have one doubt. How to read the values in excel and export to SQL? I have written the code but it throws "Unclosed String Literal" and "Not a statement" error. Could you please help ? Thanks in advance.

pstm=con.prepareStatement(sql);
String A=row.getCell(0).getStringCellValue();
String B =row.getCell(1).getStringCellValue();
String C =row.getCell(2).getStringCellValue();
String D =row.getCell(3).getStringCellValue();
String sql ="INSERT INTO tablename" + "VALUES('"+A+"',
'"+B+"',
'"+C+"',
'"+D+"')";


Can you tell me what is the error in this?

解决方案

Check this out: Read Excel values and store in to Database[^]


这篇关于从Excel读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆