Web系统与技术实验报告

上传人:M****1 文档编号:487194503 上传时间:2023-02-23 格式:DOC 页数:20 大小:642KB
返回 下载 相关 举报
Web系统与技术实验报告_第1页
第1页 / 共20页
Web系统与技术实验报告_第2页
第2页 / 共20页
Web系统与技术实验报告_第3页
第3页 / 共20页
Web系统与技术实验报告_第4页
第4页 / 共20页
Web系统与技术实验报告_第5页
第5页 / 共20页
点击查看更多>>
资源描述

《Web系统与技术实验报告》由会员分享,可在线阅读,更多相关《Web系统与技术实验报告(20页珍藏版)》请在金锄头文库上搜索。

1、090511105 蒋弨实验二 HTML Dom 编程一、实验目的1、掌握Javascript脚本编程方法2、掌握使用word,excel制作web系统的报表;3、掌握常用HTML dom 对象使用方法。二、实验内容 1、 制作Excel表格,输入web应用技术课程的学生信息,包括学号、姓名、班级等,至少录入10条记录,保存为student.xsl。2、 制作一个页面,把student.xsl的文件上传到服务器上,保存在数据库的student表中;3、 制作一个页面score.html,录入每个学生的5次平均成绩;4、在页面score.html添加两个按钮,分别把成绩信息制作成word,exc

2、el报表, 格式如下图所示。三、实验步骤1. using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.OleDb;using System.Data.SqlClien

3、t;using System.Data.SqlTypes;public partial class _Default : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) protected void Button1_Click(object sender, EventArgs e) if (FileUpload1.HasFile) try string path = HttpContext.Current.Request.MapPath(); FileUpload1.SaveAs(path + Fi

4、leUpload1.FileName); int size = FileUpload1.PostedFile.ContentLength; string type = FileUpload1.PostedFile.ContentType; Response.Write(alert(文件上传成功!); catch (Exception ex) Label1.Text = 发生错误: + ex.Message.ToString(); else Response.Write(alert(必须指定文件!); protected void Button2_Click1(object sender, Ev

5、entArgs e) string strConn = Provider=Microsoft.Jet.OLEDB.4.0;data source=E:090511101student.xls;Extended Properties=Excel 8.0; OleDbConnection connxls = new OleDbConnection(strConn); OleDbDataAdapter myDa = new OleDbDataAdapter(select * from Sheet1$, connxls); DataSet myDs = new DataSet(); myDa.Fill

6、(myDs); string mySql = ; string sqlConn = Data Source=111-41SQLSERVER2005;Initial Catalog=student;Integrated Security=True; SqlConnection con = new SqlConnection(sqlConn); if (con.State.ToString() = Closed) con.Open(); SqlCommand myCmd = new SqlCommand(); for (int i = 0; i myDs.Tables0.Rows.Count; i

7、+) mySql = (insert into STUDENT(学号,姓名,班级) values( + myDs.Tables0.Rowsi0.ToString() + , + + myDs.Tables0.Rowsi1.ToString() + , + myDs.Tables0.Rowsi2.ToString() + ); myCmd.Connection = con; myCmd.CommandText = mySql; try myCmd.ExecuteNonQuery(); Response.Write(alert(数据已成功导入到数据库!);); catch (Exception e

8、x) Response.Write(将数据插入数据库时出错 + ex.Message); if (con.State.ToString() = Open) con.Close(); 2. JavaScript代码function add()var ExcelApp = new ActiveXObject(Excel.Application); var ExcelSheet = new ActiveXObject(Excel.Sheet); ExcelSheet.Application.Visible=true; ExcelSheet.ActiveSheet.Cells(1,1).Value =

9、 This is column A, row 1;ExcelSheet.SaveAs(C:TEST1.XLS);ExcelApp.Quit(); 四、实验小结通过本次实验掌握了Javascript脚本编程方法,使用word、excel制作web系统的报表和常用HTML dom 对象使用方法。实验三 在XML文档中使用DTD和schema一、实验目的1、掌握XML DTD的定义方法及其用途;2、掌握使用元素、属性、实体和标记声明的基本语法;3、了解并掌握XML Schema的定义方法及其用途;4、了解并掌握Schema的基本结构、数据类型、元素声明和属性声明;二、实验内容 4、 根据下列要求,编写student.XML文档:(1)文档内容要求:08届(班级(学生信息(学号、姓名、电子邮件、QQ、通信地址(省份(或州)、城市、街道、邮政编码);(2)要求建立至少2个班级,每个班级至少2个学生的信息;(3)XML文档中包含以下技术的使用: a、5个预定义字符实体的使用; b、CDATA字符定界符的使用; c、属性的简单使用; d、注释的使用; e、空元素的使用。相关代码:0800310101李建国247956456广西桂林金鸡路1号5410040800310102张红247954645广西桂林金鸡路2号5410040800310201周敏12345688

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号