Server talk:Sporeggar Europe/Guild Raid Progress

=Instructions for updating= You will need:
 * Wordpad
 * Microsoft Excel

Then:
 * Update the data on Server:Sporeggar Europe/Guild Raid Progress/Raw.
 * Copy the table and paste it into Wordpad
 * Copy that text and paste it into Excel (for some reason you can't paste a HTML table directly into Excel)
 * Open the Visual Basic editor (alt-F11) and double click on ThisWorkbook in the Project pane.
 * Copy and paste appendix A into the window that appears.
 * Place the cursor anywhere in CreateFormattedWiki
 * Press F5 to run
 * It'll create a new worksheet with wiki table text in it with the formatted data.
 * Copy and paste into the relevant wiki page.

Similarly CreateRawWiki will generate a new raw table from the spreadsheet which can be pasted back in to the raw data page.

CAUTION: Remember the script here could be altered by anyone, possibly maliciously. Check the edit history for anything suspicious. Binkyuk (talk) 17:31, 11 February 2009 (UTC)

Appendix A
Private outputline As Integer Private outputsheet As Worksheet Sub emit(more As String) outputsheet.Cells(outputline, 1) = outputsheet.Cells(outputline, 1) & more End Sub Sub emitln(more As String) emit more outputline = outputline + 1 End Sub Sub reset_output(suffix As String) Dim sourcesheet As Worksheet Set sourcesheet = ActiveSheet Set outputsheet = Sheets.Add(Type:=xlWorksheet) outputline = 1 sourcesheet.Activate sheetname = sourcesheet.name & "-" & suffix For s = 1 To Sheets.Count If Sheets(s).name = sheetname Then Sheets(s).Delete Exit For End If   Next outputsheet.name = sheetname End Sub Function col_to_number(col As String) answer = 0 For i = 1 To Len(col) answer = answer * 26 answer = answer + Asc(Mid$(col, i, 1)) - Asc("A") + 1 Next col_to_number = answer End Function Sub DoSection(row As Integer, startcol As String, finishcol As String, score As Integer, pos As Integer) start = col_to_number(startcol) finish = col_to_number(finishcol) localscore = 0 span = "" For c = start To finish If Cells(row, c) <> "" Then score = score + 1 localscore = localscore + 1 span = span & " " & Cells(1, c)           If Cells(row, c) = "1" Then pos = 3 ElseIf Cells(row, c) = "2" Then pos = 2 ElseIf Cells(row, c) = "3" Then pos = 1 Else pos = 0 End If       End If    Next span = Trim(span) ' metascore is localscore bit-shifted up by 2, plus position in the bottom 2 bits. emit "| " & Format(localscore * 4 + pos) & " " If localscore = finish - start + 1 Then emitln "Clear" ElseIf localscore <> 0 Then emitln "" & Format(localscore) & "/" & Format(finish - start + 1) & " " Else emitln "" End If End Sub

Sub CreateFormattedWiki reset_output "Output"

'table header emitln "{| class=""sortable darktable""" emitln "|-"

emitln "!" emitln "! Guild" emitln "! Naxx" emitln "! Malygos" emitln "! OS" emitln "! Ulduar" emitln "! Onyxia" emitln "! ToC" emitln "! H ToC" emitln "! ICC" emitln "! H ICC" emitln "! Score"

Dim r As Integer r = 2 While Cells(r, 1) <> "" Dim score As Integer Dim pos As Integer score = 0 pos = 0 emitln "|-" emitln "| <" & Cells(r, 1) & ">" emitln "| " & Cells(r, 2)

'naxx DoSection r, "C", "Q", score, pos 'malygos DoSection r, "R", "R", score, pos 'os       DoSection r, "S", "V", score, pos 'Uld DoSection r, "W", "AS", score, pos 'Ony DoSection r, "AT", "AT", score, pos 'Toc DoSection r, "AU", "AY", score, pos DoSection r, "AZ", "BD", score, pos 'ICC DoSection r, "BE", "BP", score, pos DoSection r, "BQ", "CB", score, pos

emitln "| " & Format(score * 4 + pos) & " " & Format(score) r = r + 1 Wend emitln "|}" emitln "'Generated: " & Now & "" End Sub

Sub CreateRawWiki reset_output "Raw"

emitln "{|" emitln "|-" Dim max_c As Integer Dim widths As Integer Dim r As Integer Dim c As Integer max_c = 1 While Cells(1, max_c) <> "" emitln "! " & Cells(1, max_c) max_c = max_c + 1 Wend max_c = max_c - 1 ReDim widths(max_c) As Integer For c = 1 To max_c widths(c) = 1 Next r = 2 While Cells(r, 1) <> "" For c = 1 To max_c If Len(Format(Cells(r, c))) > widths(c) Then widths(c) = Len(Format(Cells(r, c))) Next r = r + 1 Wend r = 2 While Cells(r, 1) <> "" emitln "|-" emit "|" & Format(Cells(r, 1)) & Space(widths(1) - Len(Format(Cells(r, 1)))) For c = 2 To max_c emit "||" & Format(Cells(r, c)) & Space(widths(c) - Len(Format(Cells(r, c)))) Next emitln "" r = r + 1 Wend emitln "|}" End Sub