I have tried different gems in ruby and also searched a lot but Ruby doesnt seem to have a solution to write to existing excel file.
my excel file 'services.xls' has 3 columns
1st column name is 'inputxlm'
2nd column name is 'methodtoexecute'
3rd column name is 'output'
i have internal logic which takes the inputxlm, process it using the method and generates output
How do i write back the output to output column in 'services.xls' ?
Note : I dont want to use win32ole as my organization has some limitation on it
This article is a great source to find out which library suits you best: https://spin.atomicobject.com/2017/03/22/parsing-excel-files-ruby/
My company uses axlsx combined with axlsx_rails to render xls files with Rails rendering machine and axlsx_styler for styling.
Note that in a simple use case like the one you describe, you night not need an excel file like xls, a mere CSV would suffice, and for that, Ruby has CSV
Related
I would like to generate a DOCX with a variables inside header based on the texts inserted in the md file as variables, such as the title of the document, the version and the date of publication.
Through the yaml_metadata_block extension and the creation of custom fields in the reference.docx file I was able but I would like not to use form fields.
I understand (but I could be wrong) that with the extension pandoc_title_block this can be done but I don't understand how it works and I don't find examples on the net that I can study.
is what I said correct?
if so, could a simple example be shared that you can study and understand?
thank you
I am fairly new to selenium ruby/rspec scripting and I have come across a use case that requires data to be pulled from a csv or xlsx file in the test. Any help or suggestions on how to approach this would be greatly appreciated.
The test would pull from the csv file and input data from each row to complete the same actions against. This particular file contains a single column of "id's" and the same action would need to be repeated until all values from the column have been used. Here is the basic steps...
User logs in
User pulls first value (id) from file to search in text field
User completes action against this id
User returns to text field and pulls value from second row of same file
User completes action against this id
This would repeat until all rows are completed
Is this possible to complete the same method repeatedly but filtering through data from the file?
How would you pull the csv file into the script and specifically grab the first value (and subsequent values) throughout?
I know this is pretty vague but I have not seen any examples such as this in SO and researching online. Any suggestions or examples would very much appreciated.
I'm not sure I fully understand your question but I can try to point you in the right direction.
Ruby has a csv parser built in which you can read about here: CVS class
One of the first examples would seem to provide you with the functinoality you are looking for. I think in your example you would want to do something like:
CSV.foreach("path/to/file.csv") do |row|
#I'm assuming ID is the first element in each row
id = row.first
method_that_does_stuff(id)
# assert that stuff has happened ...
end
does that help get you started?
How to write text to excel sheet specific column or row through CAPL scripting?
The content has to be written on already existing excel sheet on specific location
Only as a scheme for further discussion as CAPL is truly not the best solution to do this:
Step 1. Open your (text) file with openFileWrite()
Step 2. Find the place in text where you want to write,
how would you do this using CAPL?
Step 3. Write text with filePutString()
Step 4. Close file fileClose()
If it is really necessary to write something into .csv (in worst case into .xls) file during a measurement, than maybe you have to try using a C library instead of hacking CAPL.
There is no API for extending CAPL to work with Excel sheets. While you might write it yourself, it's probably easier to call some external script in Python (or any other language), which gets your data as arguments and place them into specified excel sheet.
You can execute it with sysExecCmd() function.
I have created a workbook with multiple worksheets using axlsx. I've also given names to each of the worksheets. Now, I want to add content to one of the existing worksheets. Is there any way to reference the worksheet I want to add content to? That would be the easiest way.
I've also read that somewhere that you could use another gem to read the excel file then modify it. Does it have to be one with read/write capabilities like rubyXL or can I use one gem to read and then use axlsx again to write on it?
I am trying to pull product ID's, that are in Excel, into ruby to use as a temporary variable. I cannot find a simple solution and am not sure if I should use the spreadsheet gem or axlsx gem. If you guys could help get me started that would be amazing!
One simple solution would be to save the excel document as a csv. Then it would be relatively easy to to open the file with your ruby program, read in the data you need and put that into a variable, for example using the CSV library
CSV.foreach("path/to/file.csv") do |row|
# use row here
end