CSV to HTML tables
CSV to HTML tables
我很难将CSV文件显示为HTML。如何使用循环将csv文件中的下一行变成HTML表中的另一行?我还是这个jsp的新手。。。请给我一些想法让它发挥作用。
<body>
<%
String fName = "F:''web''Sales.csv";
String thisLine;
int count=0;
FileInputStream fis = new FileInputStream(fName);
DataInputStream myInput = new DataInputStream(fis);
%>
<table>
<%
out.print("<table border = 1><thead><tr><th>Customer</th><th>Customer Type</th><th>Purchase</th></tr></thead><tbody>");
while ((thisLine = myInput.readLine()) != null){
String strar[] = thisLine.split(";");
for(int j=0;j<strar.length;j++){
out.print("<td>" +strar[j]+ "</td>");
}
out.println("'n");
}
%>
</table>
</body>
Q:您不也需要在每一新行之前打印<tr>
,然后打印</tr>
吗?
还有:
-
您的
<table>
元素太多,请删除第一个。 -
我认为
<tbody>
没有必要。。。但是如果你有它,你应该用</tbody>
关闭它。
建议的改变(我实际上还没有尝试过…):
<body>
<table border = 1>
<tr><th>Customer</th><th>Customer Type</th><th>Purchase</th></tr>
<%
String fName = "F:''web''Sales.csv";
String thisLine;
int count=0;
FileInputStream fis = new FileInputStream(fName);
DataInputStream myInput = new DataInputStream(fis);
while ((thisLine = myInput.readLine()) != null){
String strar[] = thisLine.split(";");
out.print("<tr>");
for(int j=0;j<strar.length;j++){
out.print("<td>" +strar[j]+ "</td>");
}
out.println("</tr>");
}
%>
</table>
</body>
相关文章:
- 可以't让我的if语句处理js中的html表单输入
- 如何设置html元素填充的动画
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 如何将HTML id分配给元素,以及如何将JavaScript应用于元素
- 如何编写HTML输入的JS内联
- Dojo不解析自定义小部件的模板html中的小部件声明性
- 使用javascript将动态表从一个html页面打印到另一个html页
- 通过javascript重定向html传递php变量
- 如何使Javascript动态html表及其上的事件
- 在chrome.tabs.onCreated之后加载HTML页面
- 如何在vs2002中调试html页面
- 如何使用javascript或html下载PDF格式的填写表单
- 视频HTML没有'无法在Internet Explorer 11上工作
- HTML表单提交时未执行外部函数
- 如何将输入(type=text)从html表单传递到javascript函数
- 使用angular重定向到html页面
- 分析高度属性时出现意外值{{specs.height}}.index.html
- 在html Select中添加搜索
- CSV to HTML tables
- jQuery Isotope library with HTML tables