OLEDB not reading all rows from XLSX under Windows 10 and Microsoft office 2013 - oledb

I have XLSX file with 243k rows.
Same program gives different result on diffrent computers.
If i open it on Windows 8.1 + Office 2010, program reads all of 243k Rows and all works fine.
Under Windows 10+Office 2013 it reads only first 237k Rows, truncating last 6k rows.
Im using Delphi, with following connection string
ADOConnection1.ConnectionString:='Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\File.xlsx;Extended Properties="Excel 12.0;HDR=NO;IMEX=1"';
ADOQuery1.SQL.Text:='SELECT * FROM Sheet1$'
ADOQuery1.Open;
ShowMessage(ADOQuery1.RecordCount.ToString);

Problem was with table indexies and i messed up with code a bit.
Query text was taking first table name from table list instead of constant.
ADOQuery1.SQL.Text:='SELECT * FROM '
However, table indexes are different from version to version.
So selection was from different tables
Windows 8.1+Office2010 table list:
_xlnm#_FilterDatabase
_xlnm#Database
_xlnm#Print_Area
Instruction$
CATALOG$
Windows 10+Office2013 table list
_xlnm#Database
Instruction$
Instruction$_xlnm#Print_Area
CATALOG$
CATALOG$_xlnm#_FilterDatabase
But if i open file in Excel, there are only 2 sheets named : "Instruction" and "Catalog".
I dont know where the 237k rows are came from.

Related

Row and column integer error when calling load

I have a simple spreadsheet in Excel 97-2003 format, extension is XLS, that is throwing the following error when trying to load it with PHPSpreadSheet.
Error 0 on line 49 in \PhpSpreadsheet\Cell\CellAddress.php -> Row and Column Ids must be positive integer values
The spreadsheet has 14 columns with no formulas or external references. Similar spreadsheets in the same format load and process without error.
require 'PHPSpreadsheet/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
$spreadsheet = $reader->load($inputfile); // <-- this is where the failure happens
If I create a new spreadsheet and copy the rows from the one that fails into the new one the load works just fine. The header row and 1 row of data are shown below. I have tried removing the header row and manually entering a single row but get the same failure.
It seems to be related to the file itself but the error message isn't helping to determine exactly what the problem is.
DATE Course ID Title of Class StartTime PGH Location Address City State Zip Code Sponsor/Vendor Instructor if Known Contact Information Telephone
1/10/2023 7280801 Dual Credit Water & Wastewater Workshop 08:00 6 Anywhere Fire Department 123 Main St Any Town NC 28580 NC Statewide Safety Conference, Inc. Sam Smith Joe Smith 252-555-1212
This was caused by a bug in PHPSpreadsheet that was revealed by having a vertical break in row H0 for some reason.
Removing the breaks in the spreadsheet manually would also correct the problem but the latest version of PHPSpreadsheet has been fixed so it will not thrown an error if there is a vertical break in the first row.

Determine the DateTime encoding or format

I'm writing a Delphi program that needs to interact with data stored in a SQLite database that belongs to another program. Everything ok so far, except that I'm unable to get the date/time value from the data store in a column in the SQLite database, with the data type 'datetime'.
I do know that the data type of fields is not relevant in SQLite, and that everything is stored as strings, and perhaps that is possibly the reason why I find myself in this predicament.
Below is a sample of a few rows of the data stored in the SQLite database (column 3) vs. the corresponding date value displayed in the program (column 2) that reads and writes to this SQLite database:
1 11/7/1971 621939168000000000
2 3/17/1976 623314656000000000
3 5/4/1996 629667648000000000
4 9/21/2007 633259296000000000
5 11/17/1972 622264032000000000
6 2/7/1996 629592480000000000
7 6/13/2000 630964512000000000
My requirement: Once I read the value in column 3 from my Delphi program, how do I translate it to the same date/time value as displayed in column 2? I have tried the UnixToDateTime function, but it does not result in the same value (as column 2). Can anyone help?
Thanks in advance!
The value in column 3 is the number of 100 nanoseconds since 1/1/0001. You can convert it into a Delphi TDateTime like this:
theDate := (Value/864000000000) - 693593;

Extra space coming while copying records from SQL Server 2014 to Excel

I'm using SQL Server 2014, and every week I have to execute one big select query and copy those results to Excel 2013. But while copying, extra spaces are being inserted for one column so I can't get the exact format to Excel.
Screen shots:
enter image description here
enter image description here
This is split query:
Select top 1
substring (text, charindex('sets: ', text) + 6, 40)
from
di_log
where
infonum = 6
and text like 'Finished reading%Sx33%'
union all
select top 1
substring (text, charindex('sets: ', text) + 6, 40)
from
di_log
where
infonum = 6
and text like 'Finished reading%Sx33%'
When I execute on SQL Server 2012, I didn't have any problem.
I was unable to reproduce this. Are you sure your query results don't include the extra spaces?
Download the latest version of SQL Management Studio from https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms and try it again.

Open Office - How to get two different NOW() values to create a start/stop hours worked table

Column 1 is START, and column 2 is STOP. I want to start work using =NOW() in column 1 and =NOW() in column 2 when finished, but it updates the first column when I do the latter. How can I get something like this in Open Office so I can calculate a time difference for column 3, total hours/minutes/seconds worked.
In LibreOffice there is a shortcut to get a fixed time value -- Ctrl+Shift+:.
To find the difference, enter =B1-A1 in C1. Format C1 as HH:MM:SS.
The shortcut does not work in Apache OpenOffice 4.1.2. For alternatives, see https://forum.openoffice.org/en/forum/viewtopic.php?f=21&t=12575.

Excel Import : Data not being read if column has different data formats in MVC C# using linq

I am importing an excel sheet through a mvc website using linq statement as below
var members = (from memRec in excelFile.Worksheet(sheetName)
where memRec["FIRST_NAME"] != null
select memRec).ToList();
foreach (var member in members)
{
//save data
}
The problem here is let say a particular column "Date Of Birth" for first 2 columns the cell format is "DATE" and display as dd/MM/yyyy and 3rd column the cell format is "Text" and display as dd/MM/yyyy the excel will consider it as no value there for 3rd column because of format mismatch.
Is there any way to solve this.
Try declare object and use predefined data types, Like:
var q = from memRec in excelFile.Worksheet(sheetName)
where memRec["FIRST_NAME"] != null
select new Person()
{
Date = (DateTime)memRec [“Date”],
FirstName= (string)memRec [“FirstName”],
Age= (int)memRec [“Age”],
};
I found a solution.
In our server it is Office 2010.
Change the registry entry as below
In Windows environments, select Start ► Run and type REGEDIT to display
the Registry Editor.
In the registry tree, select HKEY_LOCAL_MACHINE ► Software ► Microsoft ►
Office ► 12.0 ► Access Connectivity Engine ► Engines.
Double-click the Excel node.
In the right panel, double-click the TypeGuessRows entry.
Change the value data from 8 to 0.
Click OK.
Select File ► Exit to exit the Registry Editor window.
Now the excel wont guess the row datatype since we changed the value from 8 to 0.

Resources