How can I plot this on Excel from my C program? - c++

I was once able to print an Excel equation directly to a .CSV file (which opens in Excel), which Excel would do what it would usually do when there's an equation in one of its column
Ex: (fprintf(fp,"\"=COUNTIF(R%d:AG%d,\"\">0\"\")*1.25\",",x,x);
I often print my metrics as comma separated values, since I don't know how to write directly to a new Excel file. And if there is an equation, say like the one above, Excel will compute the equation and print the values correctly.
I was wondering if there is equations similar to plot between values in two columns, so that when I open the Excel file, the plot opens too?
Has anybody done anything like this? I wish I had some Excel libraries or DLL's or something and use some Excel API's which allows me to format columns, plot graphs, etc. etc. Is something like that available out there? [Did some google-fu, didn't find anything useful. I know there's a Excel Perl module available to format outputs, save as Excel file etc.]
Thanks for help.

Related

Excel formula that checks the text of a specific column and the text of a specific row and returns the data listed in the table

I am trying to display the outcome scores on one Excel sheet into another Excel sheet based on the outcome name and course.
If the text in Sheet1!C2=communication and Sheet1!E2=Comm 2010, then display Sheet1!D2 on Sheet2!B3.
If the text in Sheet1!C4=information* and Sheet1!E4=Commm 3000, then display Sheet1!1D4 on Sheet2!C5.
Need to be able to use Wildcard when checking the text.
If the text in Sheet1!C6=communication and Sheet1!E6=Comm2010, but there is no number in Sheet1!D6, leave Sheet2!B5 blank
I have played around with a few different IF AND formulas, but I can't get the data displayed correctly.
Right now, I am building a pivot table from the data in Sheet1, then taking the table and formatting it to match the table on Sheet1 then using =IF(Pivot!C7="","",Pivot!C7). This works, but building a pivot table for each student and then formatting it to match Sheet1 is a time drain.
I'm really hoping there is a better way to do this.
Thank you!
Since you are compiling outcomes on a per-student basis and not in total it is safe to use the SUMPRODUCT() function:
The formula below is used in B3
=SUMPRODUCT((Sheet1!$E$2:$E$6=Sheet2!B$1)*(Sheet1!$C$2:$C$6=Sheet2!$A3)*(Sheet1!$D$2:$D$6))
and can be copied across and down throughout B3:C4
The formula used in B5 is different, because of the 'wildcard criterion'
=SUMPRODUCT((Sheet1!$E$2:$E$6=Sheet2!B$1)*(LEFT(Sheet1!$C$2:$C$6,11)="Information")*(Sheet1!$D$2:$D$6))
(unless you are using Microsoft 365, having the formula directly suppress 0 values essentially entails doubling it in length so, as an alternative, given the small output range, a custom-number format has been implemented, which effectively doesn't display 0 in a cell where that is the formula result)

Forcing Excel to treat a number as a string

I filled an Excel table via QXlsx (available on GitHub) with numbers that should in any case be treated as strings. In Excel the affected cells show a green triangle which says that the content is actually a number.
In Excel I found an option which suppresses the warnings. But I am searching for a solution within QXlsx. Thanks for your support.

How do I make different formatting e.g., bold, italics etc to Excel files within SAS?

I am trying to change formatting within an excel spreadsheet using SAS.
However, being a complete beginner to SAS, not sure how to go about it.
Googling lots made me get 'ODS Excel' and 'ODS Excel XP' as possible approaches.
'ODS Excel' is giving me corrupted files though, so I'm skipping that one.
Could someone please advise in detail on how to do something like below within each step I have written, preferably using 'ODS Excel XP'? Or if I am doing something wrong with 'ODS Excel' in my syntax, happy to use that as well.
Input file: /myfile.excel/
SAS:
Step 1: Read myfile.excel, which looks like this
Step 2: Turn the title row into bold text and that whole row yellow in colour, not just the cell with the text
Step 3: Output the formatting changes to new or existing excel, I don't really care
I have no idea how to do this in SAS. Could someone help, please?
Thank you!
Update: This is my SAS version: Custom Version 9.4_M3

sas adding sheets to existing excel file formatting error

I use SAS EG 6.1 to add sheets to an existing excel file (xlsx). I use a simple proc export with DBMS=xlsx. The data is written to the excelfile succesfully.
However it appears that formatting in Excel is taken from the already existing sheets. There also is a difference between cells that contains numbers vs. cells that contain text. For instance when in the existing sheet i used header 1 cell style, the numbers in the exported worksheets also had this header 1 style.
Screenshot of the existing sheet: Existing Worksheet
Screenshot of the added sheet (wrong formats)
The wrongly formatted added worksheet
I tried the following things:
- add an extra sheet without formatting and place this as first sheet in the workbook. My thought was the exported work sheets then wouldn't have the format either. No succes.
- add an extra sheet without formatting and place this as last sheet in the workbook. My thought was the exported work sheets then wouldn't have the format either. No succes.
2 alternative possible solutions i think of are:
1) using the pcfiles and ranges method. I will try this and post the results.
2) recreate the existing workbook and pray to see different results.
Did anyone have this experience and solved this problem?
update 17-1-2016: added screenshots and tried the procedure with a fresh excel workfile. The latter didn't result in succes.

Read excel column using Python code(in Linux) and get formula values

I have a pandas dataframe that looks like this:
A B C
1 2 =A2+B2
3 4 =A3+B3
I write this to an Excel file using xlsxwriter in Python and convert the data frame to Excel. Now, when I read the Excel from Python, I get 0.0 as the value for C2 and not 3 (=A2+B2). However, if I open Excel manually, the formulas are evaluated and has '3' in 'C2'. So the problem occurs while reading from code.
Is there a way in Python to read Excel columns with formulas as values?
So the problem is while reading from code.
Not really.
The issue is that XlxsWriter doesn't write the value of a formula to an Excel file. From the XlsxWriter FAQ:
Formula results displaying as zero in non-Excel applications
Due to wide range of possible formulas and interdependencies between them XlsxWriter doesn’t, and realistically cannot, calculate the result of a formula when it is written to an XLSX file. Instead, it stores the value 0 as the formula result. It then sets a global flag in the XLSX file to say that all formulas and functions should be recalculated when the file is opened.
This is the method recommended in the Excel documentation and in general it works fine with spreadsheet applications. However, applications that don’t have a facility to calculate formulas, such as Excel Viewer, or several mobile applications, will only display the 0 results.
If required, it is also possible to specify the calculated result of the formula using the optional value parameter in write_formula():
worksheet.write_formula('A1', '=2+2', num_format, 4)
I would save the Excel file as a .csv. Excel should automatically convert all formulae to values. You can then read the .csv into Python with the usual file methods.