-1

What we’re trying to accomplish is: Copy a simple, two column table (ECTS, grade) from a database application, paste the content into a HTML form, having it converted to HTML and submitted to do some PHP processing (which, fyi, is: in every tr multiply td[1] with td[2], sum all td[1], sum all td[2] – I think I know how to get this done with PHP; then, by using tcpdf, automatically create the certificates, already created that part).

For the conversion part: I tried several Javascript solutions which do work just fine (such as Help interpret/implement "Copy/Paste from Excel to a web page" answer?) – but I can't manage to put the Javascript output into a form field (input/textarea). I tried to stringify the [Object object], to no avail (JS noob here).

The best solution would be Danny Sanchez’ Tableize! (http://tableizer.journalistopia.com/) or the one from pressbin.com (http://pressbin.com/tools/excel_to_html_table/index.html) – they do exactly what we need. Alas, neither of them responds to my enquiry …

Has anyone an idea or adivse for us?

I hope I was able to explain our problem in a comprehensible way – I shall be glad to offer additional information.

("We" = A unit at a University where we, amongst other things, have to calculate grades averages which is a very exhausting task doing it by hand.)

Community
  • 1
  • 1
martvie
  • 1
  • 2
  • Why don't you just do all of this in Excel? Do you really *need* to use this particular web application ? – Tim Williams Jun 05 '13 at 16:18
  • Yes, we do. We have to do a lot of those certificates and when (not if, because it is possible) the missing link has been found, this can be done with only three clicks and thus we'll be saving a lot of time … Plus: Most data comes from a MySQL-Database, it’s only the grades and ECTS. – martvie Jun 05 '13 at 17:11
  • If you have a text area on your page then pasting directly into it from excel should give you your data as plain text (which you can then process in your php code) I'm not clear on why you then need to create a HTML table version of it? It's not as if you can post that table to a server-side script... – Tim Williams Jun 05 '13 at 17:55
  • In every row of that table are Credit Points (CP) in one and the grade (G) in the other column. For each row, CP must be multiplied by G, the result added to a variable a, while CP and G are also added to their own variable cp and g, respectively. When the script ran through all rows, a/cp = grade avg. Now, when we don’t use a table structure but plain text, we have a line which looks something like this: 7,00 1 8,00 1 4,00 3 5,00 3 (where the comma seperated values are the CP). tbc – martvie Jun 05 '13 at 18:28
  • Isn't the value of the posted text area (as read by your php script) a string with each "row" separated by a new line and each "column" by a tab? – Tim Williams Jun 05 '13 at 18:32
  • I think there is a way to achieve what we need with this line. I am just not confident in its functionality in every case as the values aren't necessarily always of the same structure. But with a , using PHP I can extract the values within without having to bother with the value’s structure … Do you understand, what I’m trying to explain? I tried to replicate this: http://stackoverflow.com/questions/10449520/tinymce-copy-paste-from-excel-plugin-bbcode but I failed miserably …
    in every
    – martvie Jun 05 '13 at 18:32
  • Well, the problem isn't the PHP processing once I posted the HTML. It’s how to geht the HTML code into the posting form’s textarea. But I’m not sure whether I have understood your last message correctly. EDIT: Do you mean to filter the values by checking for those two items (tab and linebreak)? – martvie Jun 05 '13 at 18:36
  • I mean that whatever parsing of the pasted text you're wanting to do in the client-side javascript to create the HTML table is the exact same thing you'd do server-side in php (only you're skipping the intermediate step of creating an HTML table). Just use `explode` on newline to create an array of data rows, then again on tab to create an array of column values for each line. Like this: http://stackoverflow.com/questions/3591680/copy-and-paste-price-sheet-from-excel-to-browser – Tim Williams Jun 05 '13 at 18:45
  • Thank you, Tim, for redirecting me back to PHP – finally got it working. Somehow I was so blinded with all the search results hinting on JS (which I don't like at all) that PHP (which I love) got out of my sight. – martvie Jun 06 '13 at 19:23
  • I wrote the pressbin.com tool. What exactly would you need from me? – jawns317 Mar 16 '14 at 17:54

1 Answers1

0

The OP wrote in an edit:

Solution:

if (isset($_POST['ed'])) {
    $input = str_replace(",", ".", $_POST['ed']);
    $notenarray = explode( "\n", $input);
    $gewnote = 0;
    $totalnote = 0;
    $totalects = 0;
    foreach($notenarray as $key => $val) {
        $arrayrow[$key] = preg_split("/[\t]/", $val);
        $gewnote += array_product($arrayrow[$key]);
        $totalects += $arrayrow[$key][0];
        $totalnote += $arrayrow[$key][1];
    }
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • ([Answered in the question and converted to a community wiki](http://meta.stackoverflow.com/questions/267434/what-is-the-appropriate-action-when-the-answer-to-a-question-is-added-to-the-que)) – Brian Tompsett - 汤莱恩 Nov 05 '16 at 17:28