本帖最后由 yu2n 于 2015-4-19 10:34 编辑
1. 提取内容没有问题。
2. 计算几个项目——这个就有点强人所难。毕竟贵公司考勤算法,不是谁都能完全猜得对的。题主需要提供考勤算法。
以下代码供参考,将提取网页 "Attendence Detail.htm"中"tblDetail"表格的所有内容。 | htmlfile = "Attendence Detail.htm" | | | | Dim fso, sHtml, oHTML | | Set fso = CreateObject("Scripting.FilesystemObject") | | Set oHTML = CreateObject("htmlfile") | | | | sHtml = fso.OpenTextFile(htmlfile, 1, False, 0).ReadAll | | oHTML.DesignMode = "on" | | oHTML.Write sHtml | | | | | | | | Dim oTable, sTable, nRow, nCol, sLine, sCell | | Set oTable = oHTML.getElementById("tblDetail") | | | | If Not oTable Is Nothing Then | | | | For nRow = 0 To oTable.rows.length - 1 | | For nCol = 0 To oTable.rows(nRow).cells.length- 1 | | sCell = oTable.rows(nRow).cells(nCol).innerText | | If sLine <> "" Then sLine = sLine & "," | | sLine = sLine & sCell | | sCell = "" | | Next | | If sTable <> "" Then sTable = sTable & vbCrLf | | sTable = sTable & sLine | | sLine = "" | | Next | | | | End If | | | | fso.OpenTextFile(htmlfile & ".log", 2, True, 0).Write sTable | | MsgBox sTableCOPY |
结果如下: | 日期,日期类型,进1,出1,进2,出2,进3,出3,进4,出4,工时类别,缺勤,迟到,早退,实际工作时间,加班类别1,加班单小时1,审核加班小时1,加班类别2,加班单小时2,审核加班小时2,休假类别,休假小时,进5,出5,进6,出6,进7,出7,进8,出8,进9,出9,进10,出10 | | 2015/03/24,星期二,06:50,11:47,12:24,17:36, , , , ,E&E早班, , , ,8.00,平日加班,3.00,3.00, , , , , , , , , , , , , , , , , | | 2015/03/25,星期三,06:52,11:38,12:14,17:29, , , , ,E&E早班, , , ,8.00,平日加班,3.00,3.00, , , , , , , , , , , , , , , , , | | 2015/03/26,星期四,07:04,11:36,11:55,17:17, , , , ,E&E早班, , , ,8.00,平日加班,2.50,2.50, , , , , , , , , , , , , , , , , | | 2015/03/27,星期五,06:57,11:28,12:04,17:27, , , , ,E&E早班, , , ,8.00,平日加班,3.00,3.00, , , , , , , , , , , , , , , , , | | 2015/03/28,星期六, , , , , , , , ,REST, , , , , , , , , , , , , , , , , , , , , , , , | | 2015/03/29,星期日, , , , , , , , ,REST, , , , , , , , , , , , , , , , , , , , , , , , | | 2015/03/30,星期一, , , , , , , , ,E&E早班, , , , , , , , , , ,固定年假换休假,8.00, , , , , , , , , , , , | | 2015/03/31,星期二, , , , , , , , ,E&E早班, , , , , , , , , , ,事假,8.00, , , , , , , , , , , , | | 2015/04/01,星期三,06:50,11:35,12:06,17:28, , , , ,E&E早班, , , ,8.00,平日加班,3.00,3.00, , , , , , , , , , , , , , , , , | | 2015/04/02,星期四,07:03,11:40,12:15,17:31, , , , ,E&E早班, , , ,8.00,平日加班,3.00,3.00, , , , , , , , , , , , , , , , , | | 2015/04/03,星期五,06:55,11:38,12:13,17:34, , , , ,E&E早班, , , ,8.00,平日加班,3.00,3.00, , , , , , , , , , , , , , , , , | | 2015/04/04,星期六,06:47,11:15,11:48,18:30, , , , ,REST, , , , ,公休日加班,12.00,12.00, , , , , , , , , , , , , , , , , | | 2015/04/05,星期日, , , , , , , , ,REST, , , , , , , , , , , , , , , , , , , , , , , , | | 2015/04/06,星期一, , , , , , , , ,REST, , , , , , , , , , , , , , , , , , , , , , , , | | 2015/04/07,星期二, , , , , , , , ,E&E早班, , , , , , , , , , ,固定年假,8.00, , , , , , , , , , , , | | 2015/04/08,星期三,06:59,07:37,07:45,11:40,12:14,17:33, , ,E&E早班, , , ,8.00,平日加班,3.00,3.00, , , , , , , , , , , , , , , , , | | 2015/04/09,星期四,07:02,11:30,12:01,13:13,14:51,17:16, , ,E&E早班, , , ,8.00,平日加班,3.00,2.50, , , , , , , , , , , , , , , , , | | 2015/04/10,星期五,07:03,11:34,11:58,17:28, , , , ,E&E早班, , , ,8.00,平日加班,3.00,3.00, , , , , , , , , , , , , , , , , | | 2015/04/11,星期六,07:13,11:26,11:50,18:32, , , , ,REST, , , , ,公休日加班,12.00,12.00, , , , , , , , , , , , , , , , , | | 2015/04/12,星期日, , , , , , , , ,REST, , , , , , , , , , , , , , , , , , , , , , , , | | 2015/04/13,星期一,06:53,11:38,12:11,14:02,14:23,17:34, , ,E&E早班, , , ,8.00, , , , , , , , , , , , , , , , , , , , | | 2015/04/14,星期二,07:05,11:34,12:03,17:28, , , , ,E&E早班, , , ,8.00, , , , , , , , , , , , , , , , , , , , | | 2015/04/15,星期三,07:01,11:36,12:05,17:33, , , , ,E&E早班, , , ,8.00, , , , , , , , , , , , , , , , , , , , | | 2015/04/16,星期四,07:04,11:33,12:05,17:29, , , , ,E&E早班, , , ,8.00, , , , , , , , , , , , , , , , , , , , | | 2015/04/17,星期五,07:04, , , , , , , ,E&E早班,8.00, , , , , , , , , , , , , , , , , , , , , , , | | , , , , , , , , , , ,8.00, , ,112.00, ,53.50,53.00, , , , ,24.00, , , , , , , , , , , , COPY |
|