How do I read a formatted excel worksheet as a string array
I am using the report toolkit to read a excel worksheet as a LV string array. This works fine except that it reads the full precision of numeric cells (~10 digits of precision).
In my workbook I have the displayed precision set to 2. Is there any way to read the table as it is displayed instead of how it is internally stored? (BTW, I understand how to do this
manually by parsing the string array and limiting the precision myself but would prefer to use excel itself to determine the precision)
Solved!
Go to Solution.
sachsm,
This should allow you to get the actual displayed text from an cell or range of cells. Kind of doing a 'Paste Special' 'Values'.
Attachments:
Read Excel Displayed Text.png 30 KB
Similar Messages
-
Problem in reading data from Excel sheet to 2D string array (ActiveX & LabView).
I am trying to read data from Excel sheet to 2D string array (ActiveX & LabView). Error -2147352571 is generated (type mismatch) if cell value is "#NULL!", "#N/A" etc. What should I do?
Hello �
Is the error happening when the cell value is #NULL or #NA only?
Sometimes these errors occur because of an ActiveX object mismatch. The version of the ActiveX object might have changed or been updated since the VI was created. The VI tries to use an earlier, incompatible version of the ActiveX object.
To solve the problem, you need to link automation refnum terminal to the correct ActiveX object. To do so, right-click an automation refnum terminal and choose Select ActiveX Class»Browse from the shortcut menu. From the Type Library pull-down menu, select the latest version of the library you want to use, such as Microsoft Excel Object Library. In the Objects list, select an ActiveX object, and click the OK button. Link ea
ch automation refnum terminal in the VI and its subVIs until the run arrow is not broken. Also, you might have to replace some or all of the Invoke Nodes and Property Nodes for the ActiveX objects.
Also, I came across this Knowledgebase. The error number is slightly different but it is always good to check it out and make sure it is not your case.
Hope this helps.
S Vences
Applications Engineer
National Instruments -
How to import data from all excel worksheet ?
hi
I want to import data from excel worksheet. There is a fm ALSM_EXCEL_TO_INTERNAL_TABLE but it read data only from "actual" sheet. How can I
read data from all exel spread sheets ?
krzysHi,
check this code, this is gathered from one of the thread.
report zole123.
INCLUDE ole2incl.
DATA: count TYPE i,
application TYPE ole2_object,
workbook TYPE ole2_object,
excel TYPE ole2_object,
sheet TYPE ole2_object,
cells TYPE ole2_object.
CONSTANTS: row_max TYPE i VALUE 256.
DATA index TYPE i.
DATA: BEGIN OF itab1 OCCURS 0, first_name(10), END OF itab1.
DATA: BEGIN OF itab2 OCCURS 0, last_name(10), END OF itab2.
DATA: BEGIN OF itab3 OCCURS 0, place(50), END OF itab3.
*START-OF-SELECTION
START-OF-SELECTION.
APPEND: 'name1' TO itab1, 'surname1' TO itab2,
'worli' TO itab3,
'nam2' TO itab1, 'surname2' TO itab2,
'chowpatty' TO itab3,
'name3' TO itab1, 'surname3' TO itab2,
'versova' TO itab3,
'name4' TO itab1, 'surname4' TO itab2,
'grant road' TO itab3,
'name5' TO itab1, 'surname5' TO itab2,
'gaon' TO itab3,
'name6' TO itab1, 'surname6' TO itab2,
'mahim' TO itab3.
CREATE OBJECT application 'excel.application'.
SET PROPERTY OF application 'visible' = 1.
CALL METHOD OF application 'Workbooks' = workbook.
CALL METHOD OF workbook 'Add'.
CREATE OBJECT excel 'EXCEL.APPLICATION'.
IF sy-subrc NE 0.
WRITE: / 'No EXCEL creation possible'.
STOP.
ENDIF.
SET PROPERTY OF excel 'DisplayAlerts' = 0.
CALL METHOD OF excel 'WORKBOOKS' = workbook .
SET PROPERTY OF excel 'VISIBLE' = 1.
Create worksheet
SET PROPERTY OF excel 'SheetsInNewWorkbook' = 1.
CALL METHOD OF workbook 'ADD'.
DO 3 TIMES.
IF sy-index GT 1.
CALL METHOD OF excel 'WORKSHEETS' = sheet.
CALL METHOD OF sheet 'ADD'.
FREE OBJECT sheet.
ENDIF.
ENDDO.
count = 1.
DO 3 TIMES.
CALL METHOD OF excel 'WORKSHEETS' = sheet
EXPORTING
#1 = count.
perform get_sheet_name using scnt sname.
CASE count.
WHEN '1'.
SET PROPERTY OF sheet 'NAME' = 'firstName'.
CALL METHOD OF sheet 'ACTIVATE'.
" add header here
LOOP AT itab1.
index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name " for headings change the - 1 to + 1 to accomodate 2 extra lines
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'Formula' = itab1-first_name.
SET PROPERTY OF cells 'Value' = itab1-first_name.
ENDLOOP.
WHEN '2'.
SET PROPERTY OF sheet 'NAME' = 'LastName'.
CALL METHOD OF sheet 'ACTIVATE'.
" add header here
LOOP AT itab2.
index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name " for headings change the - 1 to + 1 to accomodate 2 extra lines
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'Formula' = itab2-last_name.
SET PROPERTY OF cells 'Value' = itab2-last_name.
ENDLOOP.
WHEN '3'.
SET PROPERTY OF sheet 'NAME' = 'place'.
CALL METHOD OF sheet 'ACTIVATE'.
" add header here
LOOP AT itab3.
index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name " for headings change the - 1 to + 1 to accomodate 2 extra lines
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'Formula' = itab3-place.
SET PROPERTY OF cells 'Value' = itab3-place.
ENDLOOP.
ENDCASE.
count = count + 1.
ENDDO.
Save excel speadsheet to particular filename
GET PROPERTY OF excel 'ActiveSheet' = sheet.
CALL METHOD OF sheet 'SaveAs'
EXPORTING #1 = 'c:\temp\exceldoc1.xls' "filename
#2 = 1. "fileFormat
Note: to make headings, change the -1 to +1 where specified in the above code and add the following where i have mentioned to add it
index = row_max * ( sy-tabix - 1 ) + 1.
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'value' = header1.
Reward for helpful answers
Thanks
Naveen khan -
How Do I Call PL/SQL Stored Procedure That Returns String Array??
I Have Problem Calling An Oracle(8i) Stored Procedure That Returns Array Type (Multi Rows)
(As Good As String Array Type..)
In This Fourm, I Can't Find Out Example Source.
(Question is Exist.. But No Answer..)
I Want An Example,, Because I'm A Beginner...
(I Wonder...)
If It Is Impossible, Please Told Me.. "Impossible"
Then, I'll Give Up to Resolve This Way.....
Please Help Me !!!
Thanks in advance,// Try the following, I appologize that I have not compiled and run this ... but it is headed in the right direction
import java.sql.*;
class RunStoredProc
public static void main(String args[])
throws SQLException
try
Class.forName("oracle.jdbc.driver.OracleDriver");
catch(Exception ex)
ex.printStackTrace();
java.util.Properties props = new java.util.Properties();
props.put("user", "********"); // you need to replace stars with db userid
props.put("password", "********"); // you need to replace stars with userid db password
// below replace machine.domain.com and DBNAME, and port address if different than 1521
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@machine.domain.com:1521:DBNAME", props);
// replace "Your Stored Procedure" with your stored procedure
CallableStatement stmt = conn.prepareCall("Your Stored Procedure");
ResultSet rset = stmt.execute();
while(rset.next())
System.out.println(rset.getString(1)); -
How to Loop the Import of Excel Worksheets
The following code goes to SharePoint, downloads a worksheet from the SharePoint, copies the worksheet to an existing workbook, then renames the downloaded worksheet.
Public Sub ImportFileName()
' Define Workbook and Worksheet Variables
Dim wkbMyWorkbook As Workbook
Dim wkbWebWorkbook As Workbook
Dim wksWebWorkSheet As Worksheet
Set wkbMyWorkbook = ActiveWorkbook
' Open The Web Workbook
Workbooks.Open (webaddress_filename_ext)
' Set the Web Workbook and Worksheet Variables
Set wkbWebWorkbook = ActiveWorkbook
Set wksWebWorkSheet = ActiveSheet
' Copy The Web Worksheet, delete if already exists in this Workbook the Insert and ename
wksWebWorkSheet.Copy after:=wkbMyWorkbook.Sheets(Sheets.Count)
wkbMyWorkbook.Activate
Call DeleteFileName
wkbMyWorkbook.Sheets(ActiveSheet.Name).Name = "NewWorksheetsName"
' Close the Web Workbook
wkbMyWorkbook.Activate
wkbWebWorkbook.Close False
End Sub
I use "Call ImportFileName" to run the code. Because I have several SharePoints to import the data from, I many repeats of the above code (I just change the FileName and webaddress).
I would like to revise the above code to loop, so that I don't have to have so many "Public Sub ImportFileName()" and "Call ImportFileName" scripts.
Thank you for any assistance you are able to provide.
RichHi Rich,
I assume that you know all of the web addresses and file names so create a list of the web addresses and files in a worksheet in the same workbook that contains the code. The example code below assumes column A of Sheet3. (The list starts from row 2
because assumes a column header above the list.)
Then in the sub that calls the code to open and copy loops through the list and calls the sub to process. It passes the filename to the called sub as a parameter.
Your code calls a delete sub that you did not include but as per the comments in the example you can pass the filename to the Delete code also. Note my comments on whether this is the correct code to delete a file on the web.
Sub CommenceImport()
Dim rngFiles As Range
Dim rngCel As Range
With Worksheets("Sheet3")
'Edit "Sheet3" to the sheet name that you use for the list
Set rngFiles = .Range(.Cells(2, "A"), .Cells(.Rows.Count, "A").End(xlUp))
'Assumes list in in column A
End With
For Each rngCel In rngFiles
Call ImportFileName(rngCel.Value) 'Call the sub pass the FileName as a parameter
Next
End Sub
Public Sub ImportFileName(strFile As String)
'Sub name contains a parameter
' Define Workbook and Worksheet Variables
Dim wkbMyWorkbook As Workbook
Dim wkbWebWorkbook As Workbook
Dim wksWebWorkSheet As Worksheet
Set wkbMyWorkbook = ActiveWorkbook
' Open The Web Workbook
'Workbooks.Open (webaddress_filename_ext)
'Replace this line with following line
Workbooks.Open (strFile)
' Set the Web Workbook and Worksheet Variables
Set wkbWebWorkbook = ActiveWorkbook
Set wksWebWorkSheet = ActiveSheet
' Copy The Web Worksheet, delete if already exists in this Workbook the Insert and ename
wksWebWorkSheet.Copy after:=wkbMyWorkbook.Sheets(Sheets.Count)
wkbMyWorkbook.Activate
'I assume it is the file on web to be deleted
'if so then you can pass the file name to Sub DeleteFileName
Call DeleteFileName(strFile)
'Pass the FileName to the Delete sub
'Call DeleteFileName
wkbMyWorkbook.Sheets(ActiveSheet.Name).Name = "NewWorksheetsName"
' Close the Web Workbook
wkbMyWorkbook.Activate
wkbWebWorkbook.Close False
End Sub
Sub DeleteFileName(strFileToDelete As String)
'Sub includes a parameter to accept the file name
'Example only. May not be correct to delete a file on the web.
Kill strFileToDelete
End Sub
Regards, OssieMac -
Read data from Excel and write into oracle database
Hi
I want to know how can i read data from excel and write into oracle database using java.Kindly help me out to find a solution.
Thanks and Regards
NeetaHai,
I am suggesting the solution.
I will try out and let u know soon.
Make a coma separated file from your excel file.
Assuming that your requirement allows to make a csv file.
This file may be passed as an file object to be read by java.Using JDBC you must be able to populate the data base.You can also use String Tokenizer if needed.
You do not want to go via sql Loader?
For reading the excel file itself do you want java? -
How to check string array elements with a string with in one forEach tag ?
Hi All,
I am new to JSTL and EL. I need to change the following Java code into JSTL and EL.. I struggled to change this code into JSTL.
How can i change the if loop which tests the string array element with one bean property ?
-------------------------------------------------------------------------------------------------------------for(int j=0 ; j < iSelectedCount; j++)
if(strSelectedRoleId[j].equals(lineRole.getRoleID()))
isAvailable = true;
Please help me on this.
It is very urgent......
Thank you for ur help,
Natrajimport java.util.Calendar;
Calendar rightNow = Calendar.getInstance(); // gets the current date and time to millisec
Calendar earlyTime = Calendar.getInstance().set(Calendar.HOUR_OF_DAY, 6).set(Calendar.MINUTE, 30);
Calendar lateTime = Calendar.getInstance().set(Calendar.HOUR_OF_DAY, 8).set(Calendar.MINUTE, 0);
if (rightNow.compareTo(earlyTime)> 0 && rightNow.compareTo(lateTime) < 0){
// do something
}Try this. -
I want to print an excel worksheet so that the rows are shaded light then dark, light then dark. This helps when reading the data across the page on any selected line. Where do I select that option?
sophia beth wrote:
I want to print an excel worksheet so that the rows are shaded light then dark, light then dark. This helps when reading the data across the page on any selected line. Where do I select that option?
Not sure if it's any better in the version you have, but in earlier versions, you would have to manually select alternating rows using cmd-click in the row numbers and then fill the cells with the lightest possible shade in the fill palette. Again, in an earlier version, it is possible to use the format painter (use your Excel help for details) to select several rows formatted with the shading and paint that format to an equivalent number of rows elsewhere. -
Hello,
Can somebody suggest me how to read from an excel file (consisting of 10 work sheets) to an array?
Thanks,
SheYou have to be careful when using the spreadsheet-files vi's. They are located in the Functions Palette under File IO, you will find "Write To / Read From Spreadsheet File.vi"s.
Here is what the Context Help says about the vi function:
"Reads a specified number of lines or rows from a numeric text file beginning at a specified character offset and converts the data to a 2D, single-precision array of numbers. You optionally can transpose the array. The VI opens the file before reading from it and closes it afterwards. You can use this VI to read a spreadsheet file saved in text format. This VI calls the Spreadsheet String to Array function to convert the data. "
This is quick & easy when the spreadsheet is all the same format. You can set the format to string as well. HOWEVER... you do have to convert the Excel spreadsheet to text before using it.
I haven't experimented with the Active-X, but it may look as the way to go if you have combination text / numeric values in the spreadsheet.
If you did convert it to text, then you can use array functions as well and treating the file as an array of strings (see very brief example attached). The example is to illustrate a point only
JLV
Attachments:
starting point for spreadsheet.vi 28 KB -
How do I read a "winmail" file when it is attached to an e-mail? It doesn't open in Excel on my imac, just code...help!
Winmail is for Windows only. Excel does not open emails.
Ask the sender to send the file in a more up to date format. -
Hello,
I would use some help and more info about how to get host object that extends the functionality of my current Interop.Excel.Worksheet object. I read this artical: https://msdn.microsoft.com/en-us/library/ee794671.aspx where I can call this function
GetVstoObject to get host object. But I see that here I need to pass the Globals.Factory object as second parametar. Can someone give me more details about that parameter and how to access it? I would like to get host object so I can access extension
property, since my interop excel worksheet doesn't have it.
I am using Visual Studio 2013 for developing Excel addin. Using Excel 2010.
Thanks in advance for help.
Regards,
ZeljkaHi Zeljka,
>>I am using the Microsoft Office PIAs, so my question is how to access this automatic generated class Globals in my case? <<
Sorry, I am not able to understand the application you were developing exactly. From the orgnal post, you were developing an application level add-in, however based on the description above, it seems that you were building an console or Windows form application
to automate Office application.
If you were developing Office automation, the host item can't work for this secnario since it should run under the VSTO runtime.
If I misunderstood, please feel free to let me know.
Regards & Fei
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
How do I maintain column formatting when converting from PDF to Excel?
How do I maintain column formatting when converting from PDF to Excel? All info is no longer on the lines or in the columns they started out being in? Any help would be appreciated.
Sara,
Perhaps I am expecting too much from Adobe ExportPDF. The reason I subscribed to this service, for which I pay a yearly fee, was that I need a way to convert scanned and digital documents to Word &/or Excel. I read the link you included but to be candid the more I tried to understand what was written the more confused I got. The process should not be this difficult. Currently I am using a NEAT scanner to create PDF documents of whatever I scan. After I changed the OCR setting on Adobe ExportPDF the output was much better but not to the point it was usable as it was. Information that appears to be lines and columns are sometimes not recognizing two columns and just putting them together in one. Obviously not usable. The other thing it does is bunch numbers that appear in a column that are just a bunch of numbers that I have no way of fixing.
Please let me speak to someone who can help me. Right now I not getting anything of value in my paid subscription. -
Option to read fixed-length format, EXCEL or ASCII TAB delimited
Hi Experts,
I have a requirement for giving an option to read fixed-length format, EXCEL or ASCII TAB delimited in the selection screen.Kindly help me how can i read the fixed length format?
Thanks,
AnkitaAs far as I could have understood your problem
You have to read the file with
Open dataset 'file path+name' FOR INPUT in text mode encoding default.
and move its contents to string type variable
Transfer to 'file path+name' to v_string.
Now as per your requirements you need to use Offsets to transfer the data into a work area.
For example
wa_task-year= v_string(4).
wa_task-month= v_string+4(2).
Please confirm if this is your requirement. -
How do you load an excel worksheet to ipad ?
how do you load an excel worksheet to ipad?
You can email it to yourself, the hold your finger on it until you get options to save as pdf (viewable in ibooks, but cannot edit) or dropbox, etc.
I have Numbers app and save Excel docs in that app. This way I have capability to edit it. -
Sir I have used apple IPad 3 wifi , I need wordpad and excell worksheet for my office work. how can i found in apple ipad , or any other similar application in IPad
Satish Karanjkar.
PuneMore ways to transfer files and access Word documents:
https://discussions.apple.com/thread/4044866?tstart=0
iWork
* Keynote
* Numbers
* Pages
DocsToGo
• VIEW/EDIT/CREATE Word & Excel files(Office 2007/2008/2010)
• VIEW PowerPoint, PDF, iWork, Text, .RTF, and more!
• Send & receive attached supported documents using the built-in Mail app
• FREE desktop application with your purchase! Compatible on Win & Mac allows you 2-way file sync with a WIFI connection.
• Open & Edit files within DocsToGo from any 3rd party app that supports the “Open In” feature
• Supports iTunes File Sharing via USB cable for manually moving files
https://itunes.apple.com/us/app/documents-to-go-office-suite/id317117961?mt=8
Quickoffice Pro HD
Create and edit ALL Microsoft® Office -- document, spreadsheet, and presentation formats, as well as view PDF files, on the go. Our advanced file manager lets you manage local files, access Google Drive or other cloud accounts, and works with your iPad email attachments so you can work anywhere, anytime - online and offline.
https://itunes.apple.com/us/app/quickoffice-pro-hd-edit-office/id376212724?mt=8
Maybe you are looking for
-
I installed Arch on my MacBook (Core Duo) and it all seemed to work fine. I am dualbooting OS X so i have 4 partitions. After the install finished i ran gptsync from rEFIt and it didnt report anything, but when i went to boot, I got a black screen. S
-
SSD for system directory (boot drive)?
I'm curious why anyone would recommend an ssd drive for the system directory (boot drive). From what I read about ssd's, if there is a lot of (re)writing to the drive, the performance will degrade with time due to the way ssd's (re)allocate free spac
-
Can't burn Cds anymore!msg:"songs on playlist will not fit on one audio cd"
I recently updated my itunes library to 8--I believe--and since I haven't been able to burn any audio cds. All the settings are set correctly, the playlist size should fit on one cd, but it keeps telling me it won't fit on one cd. the cds are blank,
-
The new iTunes 12 does not have a rent tab. I've downloaded two movies which appear in the Movies folder on my Windows Explorer but not in the actual iTunes programme itself. Completely frustrating! Where can I find these two movies to watch? It aske
-
English font "Ostrich" not visible in german pages.
Hi I have a MacBook Pro, August 2013 and yosemite and latest version of pages. I have installed a free font named "Ostrich Sans". But in pages this font and a lot of others from the font collection are not visible, I suppose because they are english