How to create a pygsheets worksheet without the default sheet1? - worksheet

Is there a way to create a pygsheets worksheet without the default sheet1?
Looking through the documentation didn't help, but googling seems to indicate that it's possible to eliminate sheet1 in excel, so presumably, it should be possible in pygsheets.

sheet1 just refers to the first sheet which is automatically created when you creates the spreadsheet. It is automatically created by google sheets and you can't control it from any library. google sheets required you to have at-least one worksheet in a spreadsheet. So you cannot remove all the sheets.
But if you just want to remove the sheet named sheet1, you can do
sh.del_worksheet(sh.sheet1)
or if you wanna rename it , you can do
sh.sheet1.title="new_sheet"

Simply rename the default sheet1 to your desired worksheet name (my_sheet1)
sh = gc.create("my_google_sheet", parent_id="56uyjJcWghbtyuwA")
wks = sh.sheet1
# rename to your desired worksheet name
wks.title = ('my_sheet1')

Related

Transpose cell data into separate rows

I wanted to see if there was a formula or something that I could do to get something like this accomplished in Google Sheets.
Table 1 is the input I am getting
Table 2 is the output I want to generate on a separate sheet
I am trying to use output I get from a Google form into a Google sheet and create a CSV to import into Google Groups.
=ARRAYFORMULA(TRIM(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(IFERROR(SPLIT(B2:B, ","))<>"", "♦"&SPLIT(B2:B, ",")&
REGEXEXTRACT(A2:A, "(#.*)")&"♣"&A2:A, )),,999^99)),,999^99), "♦")), "♣")))

filter with multiple regexmatch?

my spreadsheet link with edit authorized - feel free to test any formula
https://docs.google.com/spreadsheets/d/1iY0p3_mdOfrjtBy9HPskzudf27m1mh_hApecsn0KW4A/edit#gid=1268421551
please look at the country that has statename such as P26-P38
I have 2 sheets - one is main sheet and another is named 'articles'
MAIN SHEET
ARTICLES
MAIN SHEET > on column P > I need to show the maximum date value located in column 'F' [articles!F:F]
from 'articles' sheet by finding any rows on column 'B' of 'articles' [articles!B:B]
that contains the number from column 'M' of 'Main sheet' [main!M:M]
so I use this formula
=IFERROR(MAX(filter(articles!F:F,regexmatch(","&articles!B:B,","&M58&","))))
and its working fine
but then I also need to find state name which is located in 'column E of articles'[articles!E:E]
like in the screenshot above I need to find 'Alberta' for Canada
as you can see the state name will come after '-' and follow by ':'
So it need to match both conditions and return the date
I don't know how can I define it in the formula 'regexmatch' and combine it together with the formula that I already have
I tried this but doesn't work
=IFERROR(MAX(filter(articles!F:F,regexmatch(","&articles!B:B,","&M58&","),articles!E:E,"-"&"
"&K58&":")
anyone please help, thanks
See if this works
=IFERROR(MAX(filter(articles!F:F,regexmatch(articles!B:B&articles!E:E, M59&K58&":"))))
If not, please share a copy of your spreadsheet with editing rights.
EDIT: after seeing the data, try (e.g. in P26)
=IFERROR(MAX(filter(articles!F:F,regexmatch(","&articles!B:B,","&M26&","), regexmatch(articles!E:E,K26))))
Drag up or down as far as needed.

creating multiple sheets using Coldfusion SpreadsheetWrite and cfscript

I'd like to create a single excel file with two sheets using CF9, SpreadsheetWrite and cfscript. Something like:
var data= spreadsheetNew( 'data' );
var key= spreadsheetNew( 'key');
spreadsheetAddRow( data, dataInfo );
spreadsheetAddRow( key, keyInfo );
spreadsheetWrite( data, filePath );
spreadsheetWrite( key, filePath );
I don't find documentation that explains how to combine multiple sheets in one file. Here's what I find.
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSe9cbe5cf462523a0-7b585809122c5a12c54-7fff.html
It states that one can 'Write multiple sheets to a single file.' but whether that means more than one sheet at a time is not clear. You can accomplish this using tags but I need to use cfscript.
<cfspreadsheet action="update" filename = "filePath" sheetname = "key" >
How does one write the above tag-based call using cfscript?
Yes, it is not very clear from the documentation. SpreadsheetNew creates a Workbook with a single worksheet. To add additional sheets, use the SpreadSheetCreateSheet function. Before you can manipulate the new sheet, it must be made active with SpreadSheetSetActiveSheet. Here is a quick example of creating a workbook with two sheets:
<cfscript>
// Create new workbook with one worksheet.
// By default this worksheet is active
Workbook = SpreadsheetNew("Sheet1");
// Add data to the currently active sheet
SpreadSheetAddRow(Workbook, "Apples");
SpreadSheetAddRow(Workbook, "Oranges");
//Add second worksheet, and make it active
SpreadSheetCreateSheet(Workbook, "Sheet2");
// Add data to the second worksheet
SpreadSheetSetActiveSheet(Workbook, "Sheet2");
SpreadSheetAddRow(Workbook, "Music");
SpreadSheetAddRow(Workbook, "Books");
//Finally, save it to a file
SpreadSheetWrite(Workbook, "c:/path/to/yourFile.xls", true);
</cfscript>
Side note, I would not recommend using <cfspreadsheet action="update"> anyway. Last I recall it was a bit buggy.

Apex - Interactive Report - Hide Column in CSV Download?

I've got an interactive report in Apex with some columns.
The user has the option to download the report as CSV file with the standard functionality.
Is there a way to hide a column in the export but display it on the screen.
(Background: one column is a custom link that should not be exported into the CSV)
Thank you !
Paul
You can hide it by putting a condition on the column of type PL/SQL Expression and using the following as the expression:
NVL(:REQUEST,'EMPTY') NOT IN('CSV','XLS','PDF','XML','RTF','HTMLD')
That will check the APEX bind variable "REQUEST", and if it is CSV, XLS, PDF, XML, RTF or HTML then the column will not be shown!
More info
To stop a column from showing up for an email, you can use the following:
NVL(wwv_flow.g_widget_action, 'EMPTY') != 'SEND_EMAIL'
This one did not work for me:
NVL(:REQUEST,'EMPTY') NOT IN('CSV','XLS','PDF','XML','RTF','HTMLD')
So another workaround could be the following:
instr(nvl(:REQUEST,'~'),'XLS') = 0 and instr(nvl(:REQUEST,'~'),'PDF') = 0 and instr(nvl(:REQUEST,'~'),'HTMLD') = 0
Same logic applies for csv, rtf, etc.
The most upvoted answer didn't work for me.
The workaround from #George worked for me as well:
instr(nvl(:REQUEST,'~'),'XLS') = 0 and
instr(nvl(:REQUEST,'~'),'CSV') = 0
I applied this at an Interactive Report column (APEX 21.2)

Dynamically set column in sum formula using aspose.cells

I am use aspose excel export. I am setting formulla in .net.
I want sum of two cells value in third cell. like
excelbook.Worksheets[0].Cells["A2"].R1C1Formula = "=SUM(R1C1,R1C2)";
but i want to set the column dynamically. like in above formulla column C1,C2 are fixed.
now i want pick the column name dynamically , i want to build my formulla like below
excelbook.Worksheets[0].Cells["A2"].R1C1Formula = "=SUM(R1C(Value of Cell B1),R1C(Value of Cell B2))";
so if i enter 1 in B1 cell and 3 in B2 cell then it should sum A1 and C1.i can enter any value in B1 and B2 cell and excel should calculate the sum based upon entered values.
Please suggest how to build this type of formulla.
directly in excel we can do by this way:-
=INDIRECT(B1&1)+INDIRECT(B2&1)
so please suggest can i use INDIRECT in r1c1 formulla or suggest some other way.
If you want to add D1 and E1 in Excel but you want to select the row based on the value of the particular cell; for example, in this case, you might use A1 and A2 to place the value of the row to select, then you will use the formula like this:
=SUM(INDIRECT("D"&$A$1),INDIRECT("E"&$A$2))
You can assign the same formula using Aspose.Cells for .NET as well. Please see the following code:
//create XLS File
//Instantiate a Workbook object that represents Excel file.
//create a workbook
Workbook CellsDocument = new Workbook();
//Note when you create a new workbook, a default worksheet
//"Sheet1" is added (by default) to the workbook.
//Access the first worksheet "Sheet1" in the book.
Worksheet sheet = CellsDocument.Worksheets[0];
//Access the cells and put values
Aspose.Cells.Cell cellA1 = sheet.Cells["A1"];
cellA1.PutValue(1);
Aspose.Cells.Cell cellA2 = sheet.Cells["A2"];
cellA2.PutValue(1);
Aspose.Cells.Cell cellD1 = sheet.Cells["D1"];
cellD1.PutValue(4);
Aspose.Cells.Cell cellE1 = sheet.Cells["E1"];
cellE1.PutValue(5);
Aspose.Cells.Cell cellE14 = sheet.Cells["E14"];
cellE14.R1C1Formula = "=SUM(INDIRECT(\"D\"&$A$1),INDIRECT(\"E\"&$A$2))";
//Save the Excel file.
CellsDocument.Save("output.xls", Aspose.Cells.SaveFormat.Excel97To2003);
Please try it at your end using the latest version of the Aspose.Cells for .NET. If you think it doesn't help or I'm unable to understand your question clearly then please share your further thoughts.
Disclosure: I work as a developer evangelist at Aspose.