PHP计数基于名称的单元格数据

我一直在做一些关于表单数据的手动报表,现在我得到的数据量相当大,最初是50条,现在超过了500条,所以我需要find更简单的方式来pipe理它。 我认为一个PHP程序可能会使这更容易。

基本上我有像下面的数据,我需要按用户sorting,并计算每个用户有多less主angular。

用户名| 铅源

皮特M,铅1

菲奥娜L,铅2

记住这个csv文件是相当大的,我想知道是否有人有一个更简单的方法来解决这个比我做一个手动Excel的公式。

非常感谢,

我意识到这个问题是关于PHP,但正如我build议的VBScript我认为下面可能是有用的,如果你想selectVBScript格式的报告。 多年以前,我不得不格式化一个通常需要一个小时以上的报告,并且由于源数据的改变需要再次运行 – 所以我使用了vbscript并将时间缩短到了几分钟(vb比这更复杂)

我知道下面的格式看起来很奇怪,在vbscript中没有块注释,所以使用单引号。 无论如何,希望它可以给你一个出发点。

我想我会试图使用Scripting Dictionary来维护find的每个用户的线索数量。 脚本字典的有用指南

 OPTION EXPLICIT Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 ' Const XLS_SOURCEFILE="C:\data\spreadsheet.xls" call processxls( 1, 2, XLS_SOURCEFILE, "Sheet1") ' ' the general idea is that you supply a column index ( iKeyCol ) ' and so long as there is something in that cell for each row ' the script will run ( until it hits an empty cell ) ' ' the `iKeyRow` is the row to start on - if you have column headers etc ' then after that row perhaps ' ' If you set the 3rd parameter to NULL when calling the sub you will be prompted to browse for the file to use. ' ' ' ' Sub processxls( iKeyCol, iKeyRow, filename, sheetname ) Dim oExcel Dim oXLWrkBook Dim oXLSheet Dim strFilename Dim r: r = iKeyRow '*** Get the source file *** strFilename=getfile( filename ) '*** Abandon if no sourcefile *** If( strFilename=FALSE ) Then Call KillObjects() MsgBox "Cancelled" Exit Sub End If '*** Create the excel object *** Set oExcel = CreateObject("Excel.Application") oExcel.Visible = True oExcel.DisplayAlerts = True Set oXLWrkBook = oExcel.Workbooks.Open(strFilename) Set oXLSheet = oXLWrkBook.Worksheets(sheetname) oXLSheet.Activate Do While oXLSheet.Cells( r, iKeyCol ).value <> "" On Error Resume Next '*** here is where you process your data in whatever manner you need data=oXLSheet.Cells( r, iKeyCol ).value ' increment row counter - otherwise boom! r=r+1 loop oXLWrkBook.Save oExcel.Quit Call KillObjects() MsgBox "All operations completed" End Sub Function getfile( explicitpath ) if( isNull( explicitpath ) or explicitpath=false )then Dim oShell:Set oShell = CreateObject( "WScript.Shell" ) If ( GetOSVersion() <= 5 ) Then '*** Win XP & similar *** Dim defaultLocalDir: defaultLocalDir = oShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Desktop" Set oShell = Nothing Set cd = CreateObject("UserAccounts.CommonDialog") cd.InitialDir = initialDir cd.Filter = "All Files|*.*" cd.FilterIndex = 1 If cd.ShowOpen = True Then getfile = cd.FileName Else getfile = "" End If Set cd = Nothing Else '*** Vista onwards *** Dim oExec:Set oExec = oShell.Exec( "mshta.exe ""about: <input type=file id=file><script>file.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(X.value);close();resizeTo(0,0);</script>""" ) getfile = Replace( oExec.StdOut.ReadAll, vbCRLF, "" ) Set oExec = Nothing End If else getfile=explicitpath end if Set oShell = Nothing End Function Function GetOSVersion() Dim oItem Dim oWMI:Set oWMI = GetObject("winmgmts:\\.\root\CIMV2") Dim Items:Set Items = oWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48) For Each oItem in Items GetOSVersion = split( oItem.Version, "." )(0) Next End Function Sub KillObjects() If IsObject(oExcel) Then Set oExcel=nothing If IsObject(oXLWrkBook) Then Set oXLWrkBook=nothing If IsObject(oXLSheet) Then Set oXLSheet=nothing If IsObject(oWMI) Then Set oWMI=nothing End Sub 

使用数据透视表更容易,更快捷