<?php require_once('class.textarea2csv.php'); /* * 1) initiate the class passing the $_POST data * 2) optional: set a different divider than comma (default) with function set_divider(';') or set_divider(chr(9)); options are: ; and tab * 3) call the function save_data() without parameter to get the data returned OR call the function save_data('filename') with a parameter to save the data with the given filename */
if(isset($_POST['xls']) && trim($_POST['xls']) != ''){ $csv = new textarea_2_csv($_POST); // possibility to set the divider to another format // $xls->set_divider(';'); // $xls->set_divider(chr(9));
// process data and save it with filename output $data = $csv->save_data('output');
} ?> <html> <h2>Example of class "Textarea 2 csv"</h2> <p>Copy the the content of an excel sheet, paste it in the textarea and click on "Send".</p> <form method="post"> <p><textarea name="xls" style="width: 800px; height: 400px"></textarea></p> <p><input type="submit" value="Send" /></p> </form> </html>
|