import-from-excel

Import Data from Excel in PHP [closed]

醉酒当歌 提交于 2019-11-29 02:28:20
I want to import data from excel file using PHP and then if possible, save it to a MySQL database. Importing from Excel files (XLS) is way harder than improting from CSV files. Usually I save my XLS to CSV with Excel then work on this CSV with PHP... Look at PHP function fgetcsv at: http://ca.php.net/manual/en/function.fgetcsv.php <?php $row = 1; if (($handle = fopen("test.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; }

How can I skip first several lines of the Excel sheet?

独自空忆成欢 提交于 2019-11-28 10:53:39
问题 Using openpyxl I tried to read from the fifth line for some files. The files' first four lines are the header. Then the main content has a different format from the header. And I tried the method: import openpyxl file_name="xxx.xlsx" wb = openpyxl.load_workbook(filename=file_name, use_iterators = True) first_sheet = workbook.get_sheet_names()[0] ws = workbook.get_sheet_by_name(first_sheet) for index, row in enumerate(ws.iter_rows()): if start < index < stop: for c in row: print c.value It

Reading large excel file with PHP

孤人 提交于 2019-11-28 10:23:28
I'm trying to read a 17MB excel file (2003) with PHPExcel1.7.3c, but it crushes already while loading the file, after exceeding the 120 seconds limit I have. Is there another library that can do it more efficiently? I have no need in styling, I only need it to support UTF8. Thanks for your help Filesize isn't a good measure when using PHPExcel, it's more important to get some idea of the number of cells (rowsxcolumns) in each worksheet. If you have no need for styling, are you calling: $objReader->setReadDataOnly(true); before loading the file? If you don't need to access all worksheets, or

Import Excel file into Microsoft SQL Server using C#

柔情痞子 提交于 2019-11-28 07:03:32
问题 I have a C# program that I want to import an Excel file into Microsoft SQL Server 2008 R2. Can someone give me a link or tutorial where I can fully understand on how to this? I've been doing this for a long time and I really don't have an idea on how to implement this. Please help. Thanks. 回答1: string excelConnectionString = @"Provider=Microsoft .Jet.OLEDB.4.0;Data Source=Book1.xls;Extended Properties=""Excel 8.0;HDR=YES;"""; // Create Connection to Excel Workbook We can Import excel to sql

How do I read sheet two of an xlsx file with PHPExcel?

不羁岁月 提交于 2019-11-28 04:23:41
I know how to read my xlsx spreadsheet and loop through the first sheet. It has 5 sheets and I am having trouble getting to any other than the first. Here is the code I am using which was straight from the documentation. You can see I tried to utilize setActiveSheet, but that threw the error Call to undefined method PHPExcel::setActiveSheet() . Code : $objReader = PHPExcel_IOFactory::createReader('Excel2007'); $objReader->setReadDataOnly(true); $objPHPExcel = $objReader->load("cmt_school_data.xlsx"); //$objPHPExcel->setActiveSheet(1); $objWorksheet = $objPHPExcel->getActiveSheet(); echo '

Import Data from Excel in PHP [closed]

丶灬走出姿态 提交于 2019-11-27 16:45:24
问题 I want to import data from excel file using PHP and then if possible, save it to a MySQL database. 回答1: Importing from Excel files (XLS) is way harder than improting from CSV files. Usually I save my XLS to CSV with Excel then work on this CSV with PHP... Look at PHP function fgetcsv at: http://ca.php.net/manual/en/function.fgetcsv.php <?php $row = 1; if (($handle = fopen("test.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p>

I need a workaround for Excel Guessing Data Types problem

蓝咒 提交于 2019-11-27 14:51:12
I'm creating a utility to import data from Excel to Oracle database, I have a fixed template for the excel file, Now, when I'm trying to import the data by Jet provider and ADO.Net - Ole connection tools, I found the following problem: there're some columns haven't been imported because there are mixed data types in their columns [string and number], I looked for this problem on the internet I found the reason is guessing data types from Excel The load code: connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0};Extended Properties=Excel 8.0;"); string columns =

Convert the FULL Excel date serial format to Unix timestamp

℡╲_俬逩灬. 提交于 2019-11-27 12:54:51
I've seen lots of references to converting the "date" portion of the Excel serial date format, but everyone seems to skip the "time" portion of it. Here is what I need to do: I have an Excel file I'm importing. PHP in use. I am encountering the Excel Date Serial format (dddddd.tttttt) and need to convert this to an entire Unix timestamp. I've tried a few different things, but am getting hung up on how to do this in a fluid motion. Ahmed Eissa Please use this formula to change from Excel date to Unix date, then you can use "gmdate" to get the real date in PHP: UNIX_DATE = (EXCEL_DATE - 25569) *

Text was truncated or one or more characters had no match in the target code page When importing from Excel file

我们两清 提交于 2019-11-27 12:33:02
I have an excel file with four text columns: one of them is called ShortDescription which has the longest value. I created a table in SQL Server 2008 database, with four columns and the ShortDescription column type is set to NvarChar(Max). but when using the SSIS import and export dialog, I keep getting the mentioned error in the title, even when I set the OnTruncation option to Ignore. I tried to clear the column data, and it succeeded (so I made sure that the problem is in the ShortDescription column). I tried to copy the whole data to another excel work book, and still no luck. any ideas ??

How to export data from Excel spreadsheet to Sql Server 2008 table

我的梦境 提交于 2019-11-27 11:19:09
I want to import data from an Excel file - assume Excel 2003 / .xls - to Sql Server 2008. Have tried adding a linked server to the JET OLE DB Access driver, and of course it fails on the 64-bit machine. But when I try to drop the linked server while experimenting, there's another error saying that the linked server already/still exists! I have also tried changing the Excel driver to 32-bit (regedit tool) but am not sure if it's doing anything, same error is coming up! Some more details: Say Table1 in Excel file has 5 columns. I want to map to Database.dbo.Table1 with 5 columns again, but with