Script to open excel files take info and put into new document
Hi All
I am new to applescript, but looking through the forums it seems to be the solution to my problem.
I have large numbers of excel files on a pc server which i want to open, take approx 8 cells of information from each and place into a new excel doc, forming a list. I want this if possible to happen automatically, so if a new excel document is placed into a folder on the server, the relavent information is added to my list.
I have looked at automator but dont think it works with excel yet, and the programming in excel is too much for me.
I posted a query here in my previous job for a script of change all "/" symbols to "-" symbols, which worked very well and i hope someone more gifted can help with my new query.
Hope i have given enough info and that someone can help
thanks
Supplied below is a, quick and dirty (minimal error handling), working self contained (applet) example:
on run {}
display dialog "Drag files onto applet for processing."
end run
on open (dragged_Items)
try
tell application "Microsoft Excel" -- Launch 'Excel' to process '.xls' files
set tList to {} -- Create an empty list.
repeat with i in dragged_Items -- Cycle through each dragged '.xls' file.
open i -- Open each file.
repeat with j from 1 to 8 -- Cycle through the eight column values of a single row.
copy (value of cell j of row 3) to end of tList -- Obtain individul cells' value and place into 'tList'.
end repeat
end repeat
repeat until (documents is {}) -- Routine to close all opened '.xls' windows. Here, 'close windows' does not work.
close windows
end repeat
if (not (document 1 exists)) then make new document -- Create a new document, if needed.
set k to 0 -- Location (position) of a 'tList' item.
repeat with i from 1 to (count dragged_Items) -- Set row value, of where to ener column values.
repeat with j from 1 to 8 -- Set cells' column value.
set k to k + 1 -- Increment 'tList' location.
set (value of cell j of row i) to (item k of tList) -- Enter value into current rows' columns' cell from 'tList'.
end repeat
end repeat
activate -- Bring window to foreground.
end tell
end try
end open
Save the AppleScript code as an applet (application).
Drag the desired files onto the applet for processing.
The above AppleScript code obtains the cell values of columns A through H of row 3 of each '.xls' file.
To automatically process the files of a specific folder - utilize the provided code, with respective modifications, within a
'on adding folder items to this_folder after receiving these_items
end adding folder items to
... AppleScript - 'Folder Action'.
Similar Messages
-
SQL*Loader - How to combine Flat File 3 columns and put into one single column
Receive a flat file delimited by comma. Want to combine Flat File last 3 columns and put into one single column(Table).
e.g.
Flat File
100,239,30,20,30
While inserting into table want to combine last 3 columns and insert into invoice number column.
302030It is not possible to combine the last 3 columns as those columns are seperated by commas and in the SQL Loader control file you must ve specified COMMA as an delimiter. So u better have all the columns in the table plus add one more column which holds the concatenation of the 3 columns.
Vijay -
Can't open excel file after saving and closing excel with activex
I'm using activex to write and save excel files in LabVIEW. My application opens excel (not visible)writes a file, saves it, and then closes both the file and excel. When I try to open the file Excel opens but the file is not displayed, I see the excel header and footer but the file itself does not display. My application is still running at this point. Any suggestions?
It is critical when using ActiveX with Excel that ALL refnums be properly closed when they are no longer used. Just a single refnum left open will cause the exact situation that you describe. Typically, but not required, the refnums will be closed in the reverse order in which they were created. Here is a good sequence:
Open Application ref
Property Workbooks ref
Open Workbook ref
Close Workbooks ref
Select Sheet ref
Select Range ref
Write Value2 to Range
Close Range ref
Close Sheet ref
Save Workbook
Close Workbook ref
Close Application ref
When you have properly closed all refnums, the problem will disappear.
Michael Munroe
Certified LabVIEW Developer
www.abcdef.biz
Michael Munroe, ABCDEF
Certified LabVIEW Developer, MCP
Find and fix bad VI Properties with Property Inspector -
Excel Files become "Broken" and cannot be opened
Our environment is as follows:
SharePoint 2013 server, web application running in 2010 mode. Our users are primarily on thin clients in a 64-bit Citrix environment running Office 2013 applications. We use a redirected desktop/my documents on a network drive so that users will
have their documents and settings on any computer they log into.
The issue we've run into is that sometimes one of the Excel files becomes "broken" and will no longer open. This seems to be related to when a user has the file open for long periods of time and loses connectivity or if the user's Excel /
session crashes. When the file becomes broken, the symptoms are:
Open document from SharePoint and Excel splash screen reads:
1. Starting...
2. Contacting the Server For Information. (This message lasts ~2 min)
Then an error message in Excel states:
"Microsoft Excel is waiting for another application to complete an OLE action."
OK
"Could not open 'https://sharepointurl/site/subsite/documentlibrary/document name.xlsx'."
OK
Microsoft Excel cannot access the file
'SameFilePathAsAbove'. There are several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open workbook.
OK
Empty workbook
We've had problems determining "who" broke it, but the result is the same - nobody is able to open it, whether using Excel2013, Excel2010, or the Excel Services thru the SharePoint "view in browser" option.
Our terminal servers reboot nightly, we've tried rebooting the 2 SharePoint application servers and the SharePoint SQL server to no avail. It seems like the file is stuck waiting for itself. In some cases, we've found that older versions of the
file can be restored (generally a few versions back) but when versioning is not enabled then that possibility is out.
We cannot seem to resolve where the issue lies at it's core or how to resolve it. This happens much more frequently for the documents that users keep open for long periods of time making modifications to them, but we suspect that's because they are
just more likely to have a SharePoint document open if their computer or Excel client crashes.They don't want us (the dealers) to edit the spreadsheet, but they do want us to read it. It's their pricelist, they wouldn't sell a lot of equipment if we couldn't see how much it costs! The point is that Numbers won't even open a spreadsheet that is edit protected, not read protected. This is a major issue, it should at the very least tell me I can open or import the sheet as a read only.
Excel will always open the spreadsheet, it just can't make changes to it.
For right now, when I need to get information from the pricelist in Excel, I have to copy and paste the info from the edit protected page to another blank sheet. This is a royal PITA because the Excel pricelist has 50 plus pages. I have been officially told to do that by my manufacturer. But they won't give anyone the password to unprotect the edit function of the sheet. Go figure. -
Is there a way to open Excell file from the server and display in the UI and save it back on to the
Hello there,
Is there a way to open Excell file from the server and display in the UI and save it back on to the server? (like showing xell file as a datagrid - add rows, columns etc.)Hi Mike,
Welcome you to the forum.
You may try:
SELECT * FROM MyDBNameHere.dbo.OUSR T0
Thanks,
Gordon -
I saved an Excel file yesterday afternoon, and when I opened it today, all the formatting was lost.
See:
*[[/questions/894442]] OWA 2010/Firefox 8 and ASHX Attachments
*[[/questions/895024]] -
Cannot open Excel files on Windows share and ONLY Excel files
I'm browsing a Windows share and for whatever reason it will not let me open Excel files directly from the network location. If I view the Coverflow, I can see a a preview of the actual file as well as copy it to the desktop and open it.
I receive an error message that says "filename.xls could not be found."
I can open up any other file from the network location, but not Excel files.
I checked the file permissions and they mirror the other file types, it may be worth mentioning that I utilize network synchronization and view these files from a PC as well. I also noticed when I create a new file in that location, it will only appear in OS X and not Windows, but is still completely accessible.
Any help is appreciated!
ThanksRe: Windows 8 vs. Excel problem
Does your new Dell computer have MS Office installed?
Jim Cone
Portland, Oregon USA
https://jumpshare.com/b/O5FC6LaBQ6U3UPXjOmX2 -
Open an Excel file to read and load it into Oracle - Oracle COM Automation
Hello All,
Please I need your help for this problem:
I need to load Excel sheet data (read the data) and load it into Oracle database (insert into a table), the excel file created and has data before, and saved with xls format. and I need to do that using the Oracle® COM Automation (ordcom package). The examples I found open and create a new workbook and deletes the old saved data, so I need to open (edit) the sheet just for reading.
I appreciate ans sample code to help me do that, Please help me out. This is very urgent.
Thanks alot and best regards,
NabilFor reading from Excel, there are some easy ways like Oracle Heterogenious Services. If you want to use COM then:
My orawpcom.dll file exists in the directory C:\oracle\product\10.2.0\db_2\bin
C:\oracle\product\10.2.0\db_2\bin>dir orawpco*.dll
Volume in drive C is C_Drive
Volume Serial Number is 8A93-1441
Directory of C:\oracle\product\10.2.0\db_2\bin
03/20/2006 05:06 PM 61,440 orawpcom.dll
10/11/2006 03:20 PM 81,920 orawpcom10.dll
2 File(s) 143,360 bytes
0 Dir(s) 65,407,717,376 bytes free
C:\oracle\product\10.2.0\db_2\bin>Information about my database version.
SQL> /* My databaser version */
SQL> SELECT * FROM v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
SQL> Preparing the user SCOTT for COM automation.
Now, I will run comwrap.sql from scott user. I have edited the comwrap.sql to adjust my library path here:
create library utils_lib as 'C:\oracle\product\10.2.0\db_3\bin\orawpcom.dll';Running comwrap.sql and ExcelSolution.sql .....
SQL> conn scott@orclsb
Enter password: *****
Connected.
SQL> @c:\comwrap.sql
drop library utils_lib
ERROR at line 1:
ORA-04043: object UTILS_LIB does not exist
Library created.
drop package ORDCOM
ERROR at line 1:
ORA-04043: object ORDCOM does not exist
drop TYPE OAArgTable
ERROR at line 1:
ORA-04043: object OAARGTABLE does not exist
Type created.
drop TYPE OAArgTypeTable
ERROR at line 1:
ORA-04043: object OAARGTYPETABLE does not exist
Type created.
drop function OAgetNumber
ERROR at line 1:
ORA-04043: object OAGETNUMBER does not exist
Function created.
drop function OAgetStr
ERROR at line 1:
ORA-04043: object OAGETSTR does not exist
Function created.
drop function OAgetBool
ERROR at line 1:
ORA-04043: object OAGETBOOL does not exist
Function created.
drop function OAsetNumber
ERROR at line 1:
ORA-04043: object OASETNUMBER does not exist
Function created.
drop function OAsetString
ERROR at line 1:
ORA-04043: object OASETSTRING does not exist
Function created.
drop function OAsetBoolean
ERROR at line 1:
ORA-04043: object OASETBOOLEAN does not exist
Function created.
drop function OAInvokeDouble
ERROR at line 1:
ORA-04043: object OAINVOKEDOUBLE does not exist
Function created.
drop function OAInvokeBoolean
ERROR at line 1:
ORA-04043: object OAINVOKEBOOLEAN does not exist
Function created.
drop function OAInvokeString
ERROR at line 1:
ORA-04043: object OAINVOKESTRING does not exist
Function created.
drop function OACreate
ERROR at line 1:
ORA-04043: object OACREATE does not exist
Function created.
drop function OADestroy
ERROR at line 1:
ORA-04043: object OADESTROY does not exist
Function created.
drop function OAGetLastError
ERROR at line 1:
ORA-04043: object OAGETLASTERROR does not exist
Function created.
drop function OAQueryMethods
ERROR at line 1:
ORA-04043: object OAQUERYMETHODS does not exist
Function created.
Package created.
Package body created.
SQL>
SQL> @c:\ExcelSolution.sql
drop package ORDExcel
ERROR at line 1:
ORA-04043: object ORDEXCEL does not exist
Package created.
Package body created.
SQL>
I have modified ORDExcel a little bit and renamed it as ORDExcelSB. You need this version for reading the excel.
SQL> @C:\ExcelSolutionSB.sql
Package dropped.
Package created.
Package body created.
SQL> The actual code of ORDExcelSB (ExcelSolutionSB.sql) Is:
set serveroutput on;
drop package ORDExcelSB;
CREATE PACKAGE ORDExcelSB AS
/* Declare externally callable subprograms. */
FUNCTION CreateExcelApplication(servername VARCHAR2) RETURN binary_integer;
FUNCTION OpenExcelFile(filename VARCHAR2, sheetname VARCHAR2) RETURN binary_integer;
FUNCTION CreateExcelWorkSheet(servername varchar2) return binary_integer;
FUNCTION InsertData(range varchar2, data binary_integer, type varchar2) return binary_integer;
FUNCTION InsertDataReal(range varchar2, data double precision, type varchar2) return binary_integer;
FUNCTION GetDataNum(range varchar2) return binary_integer;
FUNCTION GetDataStr(range varchar2) return varchar2;
FUNCTION GetDataReal(range varchar2) return double precision;
FUNCTION GetDataDate(range varchar2) return date;
FUNCTION InsertData(range varchar2, data varchar2, type varchar2) return binary_integer;
FUNCTION InsertData(range varchar2, data Date, type varchar2) return binary_integer;
FUNCTION InsertChart(xpos binary_integer, ypos binary_integer, width binary_integer,
height binary_integer, range varchar2, type varchar2) return binary_integer;
FUNCTION SaveExcelFile(filename varchar2) return binary_integer;
FUNCTION ExitExcel return binary_integer;
END ORDExcelSB;
CREATE PACKAGE BODY ORDExcelSB AS
DummyToken binary_integer;
applicationToken binary_integer:=-1;
WorkBooksToken binary_integer:=-1;
WorkBookToken binary_integer:=-1;
WorkSheetToken binary_integer:=-1;
WorkSheetToken1 binary_integer:=-1;
RangeToken binary_integer:=-1;
ChartObjectToken binary_integer:=-1;
ChartObject1 binary_integer:=-1;
Chart1Token binary_integer:=-1;
i binary_integer;
retNum binary_integer;
retReal double precision;
retStr varchar2(255);
retDate DATE;
error_src varchar2(255);
error_description varchar2(255);
error_helpfile varchar2(255);
error_helpID binary_integer;
FUNCTION CreateExcelApplication(servername VARCHAR2) RETURN binary_integer IS
BEGIN
dbms_output.put_line('Creating Excel application...');
i := OrdCOM.CreateObject('Excel.Application',
0,
servername,
applicationToken);
IF (i != 0) THEN
ORDCOM.GetLastError(error_src,
error_description,
error_helpfile,
error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Invoking Workbooks...');
i := ORDCOM.GetProperty(applicationToken,
'WorkBooks',
0,
WorkBooksToken);
IF (i != 0) THEN
ORDCOM.GetLastError(error_src,
error_description,
error_helpfile,
error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
RETURN i;
END CreateExcelApplication;
FUNCTION OpenExcelFile(filename VARCHAR2, sheetname VARCHAR2)
RETURN binary_integer IS
BEGIN
dbms_output.put_line('Opening Excel file ' || filename || ' ...');
ORDCOM.InitArg();
ORDCOM.SetArg(filename, 'BSTR');
i := ORDCOM.Invoke(WorkBooksToken, 'Open', 1, DummyToken);
IF (i != 0) THEN
ORDCOM.GetLastError(error_src,
error_description,
error_helpfile,
error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Opening WorkBook');
i := ORDCOM.GetProperty(applicationToken,
'ActiveWorkbook',
0,
WorkBookToken);
IF (i != 0) THEN
ORDCOM.GetLastError(error_src,
error_description,
error_helpfile,
error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Invoking WorkSheets..');
i := ORDCOM.GetProperty(applicationToken,
'WorkSheets',
0,
WorkSheetToken1);
IF (i != 0) THEN
ORDCOM.GetLastError(error_src,
error_description,
error_helpfile,
error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Invoking WorkSheet');
ORDCOM.InitArg();
ORDCOM.SetArg(sheetname, 'BSTR');
i := ORDCOM.GetProperty(WorkBookToken, 'Sheets', 1, WorkSheetToken);
IF (i != 0) THEN
ORDCOM.GetLastError(error_src,
error_description,
error_helpfile,
error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Opened ');
RETURN i;
END OpenExcelFile;
* Invoke the Excel Automation Server and create a Workbook object as
* well as a worksheet object
FUNCTION CreateExcelWorkSheet(servername varchar2) return binary_integer IS
BEGIN
dbms_output.put_line('Creating Excel application...');
i:=ORDCOM.CreateObject('Excel.Application', 0, servername,applicationToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Invoking Workbooks...');
/*i:=ORDCOM.Invoke(applicationToken, 'WorkBooks',0, WorkBooksToken);*/
i:=ORDCOM.GetProperty(applicationToken, 'WorkBooks', 0, WorkBooksToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Invoking Add to WorkBooks...');
ORDCOM.InitArg();
ORDCOM.SetArg(-4167,'I4');
i:=ORDCOM.Invoke(WorkBooksToken, 'Add', 1, WorkBookToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Invoking WorkSheets..');
ORDCOM.InitArg();
ORDCOM.SetArg('Sheet 1','BSTR');
/* i:=ORDCOM.Invoke(applicationToken, 'WorkSheets', 1, WorkSheetToken);*/
i:=ORDCOM.GetProperty(applicationToken, 'WorkSheets', 0, WorkSheetToken1);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.Invoke(WorkSheetToken1, 'Add', 0, WorkSheetToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
return i;
END CreateExcelWorkSheet;
* Invoke the Range method to obtain a range token. Then set the property value
* at the specified range to the data required
FUNCTION InsertData( range varchar2,
data binary_integer,
type varchar2)
RETURN binary_integer IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.SetProperty(RangeToken, 'Value', data, type);
IF (i=0) THEN
i:=ORDCOM.SetProperty(RangeToken, 'ColumnWidth', 15, 'I2');
END IF;
i:=ORDCOM.DestroyObject(RangeToken);
RETURN i;
END InsertData;
* Invoke the Range method to obtain a range token. Then set the property value
* at the specified range to the data required
FUNCTION GetDataNum( range varchar2)
RETURN binary_integer IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.GetProperty(RangeToken, 'Value', 0, retNum);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(RangeToken);
RETURN retNum;
END GetDataNum;
FUNCTION GetDataReal( range varchar2)
RETURN double precision IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.GetProperty(RangeToken, 'Value', 0, retReal);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(RangeToken);
RETURN retReal;
END GetDataReal;
FUNCTION GetDataStr( range varchar2)
RETURN varchar2 IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.GetProperty(RangeToken, 'Value', 0, retStr);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(RangeToken);
RETURN retStr;
END GetDataStr;
FUNCTION GetDataDate( range varchar2)
RETURN Date IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.GetProperty(RangeToken, 'Value', 0, retDate);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(RangeToken);
RETURN retDate;
END GetDataDate;
FUNCTION InsertData( range varchar2,
data DATE,
type varchar2)
RETURN binary_integer IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
i:=ORDCOM.SetProperty(RangeToken, 'Value', data, type);
i:=ORDCOM.DestroyObject(RangeToken);
RETURN i;
END InsertData;
FUNCTION InsertDataReal( range varchar2,
data double precision,
type varchar2)
RETURN binary_integer IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
i:=ORDCOM.SetProperty(RangeToken, 'Value', data, type);
i:=ORDCOM.DestroyObject(RangeToken);
RETURN i;
END InsertDataReal;
FUNCTION InsertData( range varchar2,
data varchar2,
type varchar2)
RETURN binary_integer IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
i:=ORDCOM.SetProperty(RangeToken, 'Value', data, type);
i:=ORDCOM.DestroyObject(RangeToken);
RETURN i;
END InsertData;
* Insert a chart at the x and y position of the spreadsheet with the desired
* height and width. Then also uses the ChartWizard to draw the graph with data
* in a specified range area with a specified charting type.
FUNCTION InsertChart(xpos binary_integer, ypos binary_integer,
width binary_integer, height binary_integer,
range varchar2, type varchar2) RETURN binary_integer IS
charttype binary_integer:= -4099;
BEGIN
ORDCOM.InitArg();
i:=ORDCOM.GetProperty(WorkSheetToken, 'ChartObjects', 0, ChartObjectToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
ORDCOM.InitArg();
ORDCOM.SetArg(xpos,'I2');
ORDCOM.SetArg(ypos,'I2');
ORDCOM.SetArg(width,'I2');
ORDCOM.SetArg(height,'I2');
i:=ORDCOM.Invoke(ChartObjectToken, 'Add', 4, ChartObject1);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.GetProperty(ChartObject1, 'Chart', 0,Chart1Token);
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken,'Range', 1, RangeToken);
ORDCOM.InitArg();
ORDCOM.SetArg(RangeToken, 'DISPATCH');
IF type='xlPie' THEN
charttype := -4102;
ELSIF type='xl3DBar' THEN
charttype := -4099;
ELSIF type='xlBar' THEN
charttype := 2;
ELSIF type='xl3dLine' THEN
charttype:= -4101;
END IF;
ORDCOM.SetArg(charttype,'I4');
i:=ORDCOM.Invoke(Chart1Token,'ChartWizard', 2, DummyToken);
i:=ORDCOM.DestroyObject(RangeToken);
i:=ORDCOM.DestroyObject(ChartObjectToken);
i:=ORDCOM.DestroyObject(ChartObject1);
i:=ORDCOM.DestroyObject(Chart1Token);
RETURN i;
END InsertChart;
* Save the Excel File. WARNING: Do not specify a filename that already exist
* since there is no graphical context, Oracle would not be able to pop
* out a warning message for existing file. This causes Excel to hang
FUNCTION SaveExcelFile(filename varchar2) return binary_integer IS
BEGIN
dbms_output.put_line('Saving Excel file...');
ORDCOM.InitArg();
ORDCOM.SetArg(filename,'BSTR');
i:=ORDCOM.Invoke(WorkBookToken, 'SaveAs', 1, DummyToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
RETURN i;
END SaveExcelFile;
* Close the Excel spreadsheet and exit from it
FUNCTION ExitExcel return binary_integer is
BEGIN
dbms_output.put_line('Closing workbook and quitting...');
ORDCOM.InitArg();
ORDCOM.InitArg();
ORDCOM.SetArg(FALSE,'BOOL');
dbms_output.put_line('Closing workbook...');
i:=ORDCOM.Invoke(WorkBookToken, 'Close', 0, DummyToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(WorkBookToken);
ORDCOM.InitArg();
dbms_output.put_line('Closing workbooks...');
i:=ORDCOM.Invoke(WorkBooksToken, 'Close', 0, DummyToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(WorkBooksToken);
i:=ORDCOM.Invoke(applicationToken, 'Quit', 0, DummyToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(WorkSheetToken);
i:=ORDCOM.DestroyObject(WorkSheetToken1);
i:=ORDCOM.DestroyObject(applicationToken);
i:=ORDCOM.DestroyObject(ChartObjectToken);
i:=ORDCOM.DestroyObject(Chart1Token);
i:=ORDCOM.DestroyObject(ChartObject1);
i:=ORDCOM.DestroyObject(dummyToken);
RETURN i;
END ExitExcel;
END ORDExcelSB;
/I have created an excel named as C:\Example.xls.
Name SlNo Job Dept Salary Bonus
Saubhik Banerjee 706090 IT Specialist GBS 100 10
Partha S Mohanty 706091 Pogrmmer APPS 70 20
Partha Sarkar 889300 Condultant FIN 200 30
Useless 98009 PM PM 900 90
SQL> SET SERVEROUT ON
SQL> DECLARE
2
3 v_Name varchar2(90);
4 v_SlNo varchar2(100);
5 v_Job varchar2(200);
6 v_Dept varchar2(100);
7 v_recon_remark varchar2(50);
8 v_sal_amt_usd number;
9 v_Bonus_amt_usd number;
10
11 result INTEGER;
12
13 i binary_integer;
14 filename varchar2(255);
15
16 BEGIN
17
18 filename := 'C:\Example.xls';
19
20 result := ORDExcelSB.CreateExcelApplication('');
21 result := ORDExcelSB.OpenExcelFile(filename, 'Sheet1');
22
23 /* Excluding the header row and reading the first 5 row */
24 FOR n in 2 .. 5 LOOP
25
26 v_Name := ORDExcelSB.GetDataStr('A' || n);
27 v_SlNo := ORDExcelSB.GetDataReal('B' || n);
28 v_Job := ORDExcelSB.GetDataStr('C' || n);
29 v_Dept := ORDExcelSB.GetDataStr('D' || n);
30 v_sal_amt_usd := ORDExcelSB.GetDataNum('E' || n);
31 v_Bonus_amt_usd := ORDExcelSB.GetDataNum('F' || n);
32
33 dbms_output.put_line(v_Name || ' ' || v_SlNo || ' ' || v_Job || ' ' ||
34 v_Dept || ' ' || v_sal_amt_usd || ' ' ||
35 v_Bonus_amt_usd);
36
37 END LOOP;
38
39 result := ORDExcelSB.ExitExcel();
40 EXCEPTION
41 WHEN OTHERS THEN
42 result := ORDExcelSB.ExitExcel();
43 RAISE;
44 END;
45 /
Creating Excel application...
Invoking Workbooks...
Opening Excel file C:\Example.xls ...
Opening WorkBook
Invoking WorkSheets..
Invoking WorkSheet
Opened
Saubhik Banerjee 706090 IT Specialist GBS 100 10
Partha S Mohanty 706091 Pogrmmer APPS 70 20
Partha Sarkar 889300 Condultant FIN 200 30
Useless 98009 PM PM 900 90
Closing workbook and quitting...
Closing workbook...
Closing workbooks...
PL/SQL procedure successfully completed.
SQL> Although, You haven't asked, but you can use this code to write to excel file (.xls)
DECLARE
CURSOR c1 IS
SELECT empno, ename, dname, sal, hiredate
FROM emp e, dept d
WHERE e.deptno = d.deptno;
error_message varchar2(1200);
n binary_integer:=2;
i binary_integer;
filename varchar2(255);
cellIndex varchar2(40);
cellValue varchar2(40);
cellColumn varchar2(10);
returnedTime varchar2(20);
currencyvalue double precision;
datevalue DATE;
empno binary_integer;
looptext varchar2(20);
error_src varchar2(255);
error_description varchar2(255);
error_helpfile varchar2(255);
error_helpID binary_integer;
begin
filename:='c:\example2.xls';
i:=ORDExcel.CreateExcelWorkSheet('');
i:=ORDExcel.InsertData('A1', 'EmpNo', 'BSTR');
i:=ORDExcel.InsertData('B1', 'Name', 'BSTR');
i:=ORDExcel.InsertData('C1', 'Dept', 'BSTR');
i:=ORDExcel.InsertData('D1', 'Salary', 'BSTR');
i:=ORDExcel.InsertData('E1', 'HireDate', 'BSTR');
For c1_rec IN c1 LOOP
cellColumn:=TO_CHAR(n);
cellIndex:=CONCAT('A',cellColumn);
cellValue:=TO_CHAR(c1_rec.empno);
empno:=cellValue;
i:=ORDExcel.InsertData(cellIndex, empno, 'I2');
cellIndex:=CONCAT('B',cellColumn);
cellValue:=c1_rec.ename;
i:=ORDExcel.InsertData(cellIndex, cellValue, 'BSTR');
cellIndex:=CONCAT('C',cellColumn);
cellValue:=c1_rec.dname;
i:=ORDExcel.InsertData(cellIndex, cellValue, 'BSTR');
cellIndex:=CONCAT('D',cellColumn);
cellValue:=c1_rec.sal;
currencyValue:=cellValue;
i:=ORDExcel.InsertData(cellIndex, currencyValue, 'CY');
cellIndex:=CONCAT('E',cellColumn);
dateValue:=c1_rec.hiredate;
i:=ORDExcel.InsertData(cellIndex, dateValue, 'DATE');
n:=n+1;
END LOOP;
i:=ORDExcel.SaveExcelFile(filename);
i:=ORDExcel.ExitExcel();
EXCEPTION
WHEN OTHERS THEN
i:=ORDExcel.ExitExcel();
RAISE;
END; -
Need to open excel file and read comment field on ipad
Hi,
I need to open excel files on my ipad and read the comment fields that our ofiice wrote for me . But this doesn´t work .
I tried it over several apps (office2HD, etc.) but with no result.
It´s also necessary to work on our office google drive for me ..
Can someone help me with this problem???
BR
GunnarCALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = 1
i_begin_row = 4
i_end_col = 12
i_end_row = 60000
TABLES
intern = it_excel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF NOT it_excel[] IS INITIAL.
SORT it_excel BY row col.
LOOP AT it_excel.
CASE it_excel-col.
WHEN 1.
it_file-hiden = it_excel-value.
WHEN 2.
it_file-budat = it_excel-value.
WHEN 3.
it_file-ltext = it_excel-value.
WHEN 4.
it_file-subsystem = it_excel-value.
WHEN 5.
it_file-work = it_excel-value.
WHEN 6.
it_file-role = it_excel-value.
WHEN 7.
it_file-sgtxt = it_excel-value.
WHEN 8.
it_file-company = it_excel-value.
WHEN 9.
it_file-megbtr = it_excel-value.
WHEN 10.
it_file-realbtr = it_excel-value.
WHEN 11.
it_file-comment = it_excel-value.
ENDCASE.
AT END OF row.
APPEND it_file.
CLEAR it_file.
ENDAT.
ENDLOOP.
ELSE.
MESSAGE i000 WITH 'The input file is empty'.
STOP.
ENDIF. -
Is there way to have Numbers open excel files automatically
Is there way to have Numbers open excel files automatically when I click on my old excel files rather than opening numbers and then opening file?
Try this: from Finder, select an Excel file. Hit Apple-i to get the file info. You'll see a section labeled *Open with:* Use the dropdown to select Numbers and click the *Change All* button.
-
Spreadsheet app that opens Excel files?
I should have asked this in my last post about word processors in OS X. If I'm just a casual user who rarely needs to open Excel files (e.g. friends email me some spreadsheet about who knows what), should I just plan on using NeoOffice (OpenOffice), or is there some other option out there if I don't want to buy MS Office? It seems that iWork doesn't even come with a spreadsheet app. However, even if it did, I'm wondering if there'd be another alternative sufficient for a casual user like myself.
Mac OS X (10.4.6)NeoOffice handles multiple sheets and has loaded my Excel files with no problems. I have not used NeoOffice extensively as I downloaded it to become familiar with what it can do, so I have not come up against its limitations yet. NeoOffice is a large program (338 mb on my external hard disk) which contains all the modules in one (rather than separate programs like Word, Excel and PowerPoint), so it takes a while to initially open but once open it switches between the modules with little delay.
-
Problem opening excel files exported from Discoverer Plus 10.1.2.48.18
I can't open excel files (xls) exported from Discoverer Plus 10.1.2.48.18 when I enable macros. The application (Excel) hangs up.
Someone have any idea about this?
Thanks,
DiegoHi Meifang
I did some more research and found a document on MetaLink 250820.1 that talks about Discoverer not being able to call Excel if Discoverer is running via an IP address instead of a qualified domain name.
The article talks about making Discoverer a trusted site in the Internet Options of IE. Here's the relevant info from the posting:
Workaround for MS IE (if necessary):
1. Open a new MS IE browser
2. Navigate to: Tools | Internet Options Security where you will see the Trusted Sites icon (green icon with a check mark)
3. Click the Sites button
4. Add the following: http://IP:port/
(where IP, port are the location of where Discoverer server is running)
5. Click the OK button
6. Click the OK button again
On my own PC, I was having a similar problem and I was unable to get Excel to launch. In the end I did this:
1. Open a new MS IE browser
2. Navigate to: Tools | Internet Options | Security where you will see the Local Intranet icon (computer icon against a globe)
3. Click the Local Intranet button
4. Click the Sites button
5. Click the Advanced button
6. Add the following: http://IP/ or http://website
(where IP or website are the location of where Discoverer server is running)
7. Click the Add button
8. Click the OK button
9. Click the OK button again
10. Click the OK button a third time
With this done, I made sure that my Explorer settings were correct by doing the following to ensure that a couple of settings for the .xls & .html file types are unchecked:
1. Open Windows Explorer
2. Navigate to: Tools | Folder Options | File Types tab
3. Highlight the Extension XLS (or HTML)
4. Click the Advanced button
5. At the botton of the screen are three settings that use checkboxes. If either of the following two are checked, un-check them:
Confirm Open after Download and Browse in same window
6. Click the OK button
7. Click the Apply button
8. Re-boot the PC
After I did this I was successfully able to get Excel to open from within Discoverer.
Best wishes
Michael -
Indesign Script for placing excel-file
Hi all, I'm new to Indesign Scripting, and I'm hoping someone can help me with the following code:
All I want to do is:
open indesign file
open excel file
place excelfile as a table (with flow enabled)
save document & export as PDF
Thanks!
//Define file to open
var myDocumentFile = new File("/d/Projecten/Indesign Server/document.indd");
//Define file to save
//var mySaveFile = new File("/d/Projecten/Indesign Server/document_save.indd");
//Define file to export
var exportPDF = new File("/d/Projecten/Indesign Server/document_save.pdf");
//Open xls-file to place as table
var myExcelFile = new File ("/d/Projecten/Indesign Server/products.xls");
var result = "";
if(!myDocumentFile.exists) {
result = "Unable to find DOCUMENT: " + myDocumentFile.path;
$.writeln(result);
exit();
} else if(!myExcelFile.exists) {
result = "Unable to find EXCEL: " + myDocumentFile.path;
$.writeln(result);
exit();
} else {
// Open file
var myDocument = app.open(myDocumentFile);
with(app.documents.item(0).pages.item(0)){
myTarget = textFrames.item("tabel");
var myPage = myDocument.pages.item(0);
//Set excel placement properties
setXLimportPrefs();
// Place Excel file
try {
$.writeln("Place Excel file");
//HELP!! HOW TO PLACE EXCEL FILE?
//myTextFrame.place(myFile);
catch (e) {
$.writeln("Place Excel file " + e + " " + app.excelImportPreferences.errorCode);
myDocument.close();
exit();
if(!exportPDF.parent.exists && !exportPDF.parent.create()) {
result = "Not exported. Unable to create the folder: " + exportPDF.parent.fullName;
$.writeln(result);
} else {
app.documents.item(0).exportFile(ExportFormat.pdfType, exportPDF, app.pdfExportPresets.item("[Press Quality]"));
myDocument.exportFile(ExportFormat.PDF_TYPE,exportPDF);
myDocument.close();
function setXLimportPrefs(){ $.writeln("setXLimportPrefs()");
with(app.excelImportPreferences){
//alignmentStyle property can be:
//AlignmentStyleOptions.centerAlign
//AlignmentStyleOptions.leftAlign
//AlignmentStyleOptions.rightAlign
//AlignmentStyleOptions.spreadsheet
alignmentStyle = AlignmentStyleOptions.spreadsheet;
decimalPlaces = 4;
preserveGraphics = true;
//Enter the range you want to import as "start cell:end cell".
rangeName = "A1:B16";
sheetIndex = 1;
sheetName = "Appetizers";
showHiddenCells = false;
//tableFormatting property can be:
//TableFormattingOptions.excelFormattedTable
//TableFormattingOptions.excelUnformattedTabbedText
//TableFormattingOptions.excelUnformattedTable
tableFormatting = TableFormattingOptions.excelFormattedTable;
useTypographersQuotes = true;
viewName = "";
result;"I just loaded a table into a text frame but it still contains nothing". I wonder how I'd check that, actually.
@Jongware:
To prevent this situation you could set the max. allowed cell height below your min. text frame height.
If this is not applicable, because in some situations you cannot know the usable text frame height beforehand, you can iterate through all your set rows and check if the parentTextFrames[0].parentPage.name property of the first insertionPoint of its first cell is defined. If it's undefined and your last text frames parentPage.name is not equal to the last defined parentPage.name of your check your table will remain overset.
Thinking about that method I must admit, that you can get a false positive, if a text wrap object on an applied master page comes into play…
So no, I see no fail-safe check for this situation.
Uwe -
How to list all currently open Excel files with ActiveX?
Hello all!
I would like to program with ActiveX a way to retrieve a list (array of strings) of the filenames of the currently opened Excel files in windows. However, I am fairly new to the ActiveX/Excel business in LV and after hours looking at the "millions" of objects in the property nodes I give up and hope some kind soul here can help me. I couldn't find any information in this forum regarding the same issue, although some were close
I am using LV 7.1 without the Report Generation Toolkit.
Thanks!
/GoranHi KC,
thanks for your reply. I have in fact been able to find the desired things in the ActiveX properties/methods for Excel in LabView. It took me some looong work going through the functions which I suspected to be the ones. Anyway, I post a little jpeg here of the code if someone ever needs the same functionality. What it does is that it checks how many Excel workbooks are open and controls if each of them matches the searched Excel filename, if one does, it is closed.
Enjoy
/Goran
Attachments:
List open excel sheets and close open ones.jpg 104 KB -
I have some users in my company that can't open Excel files from any document libraries on SharePoint 2010. The receive the error message "An error occurred. Please try again." We don't currently use the Excel calculations services. When
a user opens an excel file they are prompted to either Read Only or Edit.
This affects less than 5 people in a large company. They have the Full Control permissions and have been able to open the files previously. There has been no changes made to the server either. I can't find anything that points to this in the
event viewer.
It doesn't matter if which computer that they try to open this up from either. All computers are Windows 7 Professional with IE 9 and Office 2010 x64.
I can't find anything that points specifically to this exact error. None of the excel files contain pivot tables. This one has me stumped.I would make sure no one has open on machine / locked on machine (Would assume you checked this, but wanted to add)
Also would have assumed you restarted the machines (:))
Make sure the file security did not change (check to ensure no one changed the sercuity of the excel)
Make sure the version of excel is the same (Changing from 2010 back to 2007 affects the file, etc.. on convert) that no one converted and saved thus causing error in file.
Can they open other excel files?
It sounds like the excel file it self has changed if you cannot see issue in SharePoint logs.
If it is all SharePoint excel files - try deleting one persons access and readding them to see if that helps.
SharePoint has issues ;)
Maybe you are looking for
-
Safari cannot handle pdf and forms
I have two G4s using Tiger and Safari, identical settings. One can read pages which have pdf, and can fill out pdf forms. The other (newer) G4 cannot fill out pdf forms. I made sure that both have the same plug-ins in Library>Internet plug-ins, and n
-
Can I use coldfusion 8 standard version in Sun / Solaris?
Hi, I would like to know if I can use coldfusion 8 standard version in Sun / Solaris Thank you.
-
Hi, could you please help me with a code for delimiting the record in SAP, we are using a certain bapi for deleting or amending the back end record when user makes change in data at the UI
-
In Mail 6.3 on 15" Macbook pro, an email received show a bunch of A's in square boxes. On an Identical Laptop, everything shows up fine. I cant find any configuration differences, but I may not know where to look. Any help out there?
-
Filter / Sort by Bit Depth? (16 bit vs 8 bit)
I am looking for a way to use the Filter panel to sort/filter results by bit depth (16 bit vs 8 bit images) - is there a way to do this Bridge CS4? I have looked in every part of the sorting mechnisms and can't find a way. Am I missing something?