Adding new sheet to existing spreadsheet via Google sheets api v4 - java

I've been facing an issue within adding a new sheet (tab) to existing spreadsheet.
Before the main issue, I will try to explain why I need to do such a thing and maybe there will be other solution. I'm trying to upload spreadsheet with several sheets. When sheets have smaller size, everything is ok. But when I do the "service.spreadsheets().create(spreadsheet).execute()" request with really big sheets (like two sheets with 40k cells), I get normal response, but created spreadsheet contains only empty "Untitled document" with empty tab. That's first thing which bothers me, why I don't receive something like "your insert is too big" or something like that.
So I would like to create spreadsheet, insert first tab (as a smaller request) and then add another tab (sheet) and so.. But what I only found over the stack and google documentation is "BatchUpdateSpreadsheetRequest". But this request doesn't allow me to add already created sheet, it just create new empty sheet, which is really annoying.
Do I miss some API call? Also I found over the documentation and stack some limits, but there is no clear info about how big can be requests with sheets (I've seen all the 400k rows, and what you can found here), but that didn't help a lot.
Can someone provide me info how to "split" spreadsheet creation into creating more smaller request so the created spreadsheet will contain all the data?
Thanks

The V4 API currently has a limit of 10MB of data per request, though I don't think we advertise this fact in the documentation anywhere right now.
To workaround, you can use multiple different requests in a BatchUpdateSpreadsheetRequest -- an AddSheetRequest as you mentioned, plus UpdateCellsRequest, or some number of other requests. Check out the guide that details what requests deal with what portions of the spreadsheet.
If you have specific portions of the spreadsheet you're curious about how to set, please follow up.

Related

Selenium/TestNG DataProvider - How to structure Excel sheets in combination with Page Object Model

Background
I am developing a new approach to automated testing using Selenium/TestNG/POM. So far, we have very promising results and automated large parts of our regression testing.
Now, we came to the step of expanding our test set by parametrizing them. We have end2end flows defined over multiple pages, where the pages are modeled into page objects. Most of these pages are forms, and in the end we get a resulting product/report that combines all the information.
Now my problem statement
We want to use Excel sheets so our business analysts can input the parameters and the expected values. But I am struggling to find a good way to structure the sheets. The naive approach would be to have a column for every parameter, and a line for every test case. A slightly better approach would probably be to use a different sheet for each page object, in a workbook, having a different workbook for each flow.
But my fear is that, by doing this, we are undoing all the good the POM brings us. If we need to change something (add a field in one of the screens for example), we need to regenerate all the excel sheets, or at least manually update each one. This is not that much better than having to update each scenario. In fact, we probably still have to edit all the scenario's (for example, if the new field is "name", add everywhere a "fillName('John')" step.
Is there a better way? Or is the manual work unavoidable? Or am I implementing POM incorrectly if I still need to adapt most scenarios everytime I need to add a field?
Trying to create yet another solution which use Excel as page object source you are bringing youself back to stone age. Use modern frameworks to handle Page Objects issues e.g. JDI with elements typification or Selenide wich provides more concise way.

How can i change text orientation in XWPFDocument?

I am working right now in producing word documents in java and i am using XWPFDocument of POI Apache. The final document must looks like this
http://sk.uploads.im/t/rtwvm.png
till no everything works fine, I created table, managed to merge cells but i can not find a way to change the text orientation in table cells. I simply want "Type 1" to be upward.
I only found a solution using cellStyle which seems to work only in excel and not in word, which i am using.
You probably need to create two documents in Word, one with the normal orientation and one with the changed one, then unzip them (.docx is actually a Zip-File) and analyze which xml-structure is responsible for this.
Then you can check if POI already offers higher level APIs for these or if you need to access the low-level POI classes via the getCTxxx() methods, e.g. XWPFTableCell.getCTTc() returns the underlying XML structure and allows you to do things that are not possible via the normal POI interfaces.
You can use something like: cell.getCTTc().getTcPr().addNewTextDirection().setVal(STTextDirection.BT_LR),
where the parameters are found in: STTextDirection.
The problem I couldn't solve yet is that the row height does not update automatically to the vertical text length, then the text is not completely showed. If you solve it, please, post here.

Google Spreadsheet Java API - Protect Worksheet

Is it possible to programmatically protect a worksheet in a spreadsheet to only allow specific people to edit it?
I can't find any decent documentation or examples on how to do this. The only things I can find that may be relevant are the setRights()/getRights() and getContributors() methods in BaseEntry.java, which I don't think are any good, but I don't know because there's no documentation.
Is there are feed URL I can post to to update the list of contributors?
Thanks for any help.
Google-apps-script
Looks to be possible with Google-apps-script
https://developers.google.com/apps-script/reference/spreadsheet/sheet#setSheetProtection(PageProtection)
Gdata - spreadsheet api
there is nothing close to that in the spreadsheet api. Even basics
like set cell color or insert row don't exist. (there an append row)
It works fine for data and calculation but little else.

What technologies are there for formatted, structured data input and output?

I am working on a project here that ingests internal resumes from people at my company, strips out the skills and relevant content from them and stores it in a database. This was all done using docx4j and Grails. This required the resumes to first be submitted via a template that formatted everything just right so that the ingest tool knew what to look for to strip the data.
The 2nd portion of this, is what if we want to get out a "reduced" resume from the database. In other words, I want to search the uploaded content I now have, and only print out new resumes for people who have Java programming experience lets say. So I can go into my database, find the people who originally had java as a skill, and output a new set of resumes that are also still in a nice templated format, and only have the relevant info in them, instead of ALL the content.
I have been writing some software to do this in Java that will basically use a docx template, overwriting the items in customXML which are bound to the content controls in the doc, so the new data shows up and can eb saved as a new docx with that custom data.
This seems really cumbersome to me, and has some limitations. For one, lets say my template has a place for 3 Skills, and the particular person has 8 skills. There seems to be no good way to add those 5 additional skills to the docx other than painstakingly inserting the data with all of the formatting XML tags and such. This is a real pain, because if the template changes, I dont want to have to go back into my software and edit source code to change that additional data input XML tag to bold instead of italic.
I was doing some reading up on using Infopath to create a form that I could use to get the input, connecting to some sharepoint data source or something to store the stripped out data. However, I can't seem to find out if it is possible using sharepoint to get the data back out, in a nice formatted way. What would the general steps for this be? It seems like I couldnt find very much about this topic with any quick googling.
Thanks
You could set up the skills:
<skills>
<skill>..</skill>
<skill>..</skill>
and use a "repeat" content control pointing to the container. This would handle any number of <skill> entries.

POI dynamic templates

Can anyone tell me where do I find some useful documentation on handling copying rows, cells, columns from one excel file to another, using POI?
I need to insert in one blank excel file, 2 or more templates from other files, dynamic.
I also need to keep all the styles made for the group of cells that I copy. How can I do that? Nothing found on apache poi tutorial on this point.
I am using POI 3.0.1.
Thank you!
I assume the problem is data types and merged cells? It's easy enough to get and set styles and set values.
Depending on your use case, you might be able to take entire sheets from the original document, assemble the new document from those and tweak it to your liking. Even if you have to combine multiple source sheets into one target sheet, you might still be able to retrieve source rows and assemble the target document from those rows.
...that was me some time ago...
I never could copy from one excel file to another with the exact style, but I found a solution : I used multiple worksheets instead of multiple excel files, cause style has no problem in being copied from one sheet to another as long as it is in the same workbook.
I also migrated from POI3.0.1 to POI 3.6. Far much better.

Categories

Resources