Data is reflected only when the Excel sheet is manually saved - c#

I have an Excel report generation app using EPPlus. In one of sheets the formulas are getting dynamically updated, formulas referencing other sheets data. When I open the generated report I am able to see the formulas but the data is getting reflected only when I manually save the Excel sheet.
The reference sheet was also dynamically added, but when I changed it to static sheet the issue persisted.
Do I need to call some other function to update the formulas?

ok got it.
I need to call
package.Workbook.Calculate()

Related

Update Stylesheet of an existing Excel file using openXML

I am trying to copy an Excel workbook with 4 worksheets (tabs) where 1 worksheet is macro enabled with many formulas using the OpenXML SAX approach as I have lot of data for each sheet.
If I copy the file and and start writing into the worksheets, it starts writing from the 1st line and the headers are being deleted. So I tried copying just the macro-enabled sheet and add other sheets later and add styles to headers.
When I try doing it, the system give an error saying only one style sheet is allowed. Only one instance of the type is allowed for this parent.
How can I access the existing stylesheet and add more styling into it for other tabs?

Dynamic Excel columns and rows to SQL

I have an Excel template which has dynamic rows and columns (it means the Excel template will be downloaded based on the parameters I select in my UI). Now there will be some data in the Excel sheet against those dynamic rows and columns coming from the database. I want to modify that Excel and import it so that only the updated(modified) cell values are updated in database. I thought a lot and I think this can be done with macros (by changing the color of cells with updated values and picking them up from C#). I would welcome any other thoughts/approaches for this.
An approach I have used is to create a webdav/REST service which can then be mounted as a drive in Windows.
The exposed file on the webdav service was simply a CSV, which users could edit in Excel, but the GET request was serviced by reading the database.
After making the changes, the user saved in Excel, which caused a PUT on the webdav service. The PUT request wrote the new values to the database.

Create an external reference between cells in different workbooks C#

I have Two Excel Files
abc.xlsx
--Summary
xyz.xlsx
--Summary
I want to give Reference of one cell from abc.xlsx excel File to xyz.xlsx file
ws.Cells[1, 4].Formula = "('[abc.xlsx]Summary'!$D$36)";
But it is not working
The issue is that Excel formulas linked to other workbooks doesn't update automatically (without opening the source) but when i open the source workbook it automatically update itself.
Can any one suggest a correct answer
I m using https://epplus.codeplex.com/
Thanks
Formulas can't update without an instance of Excel to update them. Excel files are not standalone.

Retrieve dynamic values from Excel

Objective
To retrieve values from Excel sheet that is changing each second.
Efforts so far
Created shared excel file so that it can be retrieved by more than two processes simultaneously.
Tried to read excel file that is receiving updates from RTD Server. The file is changing cells values each second. I read it by using Microsoft.Office.Interop.Excel
Simultaneously accessing data from excel file into GridView using System.Data.OleDb.
Looking for
How to read those dynamic values from excel sheet? Because until those values are not saved, I can't read them from code they way I am doing now.
I believe that there should be way for accessing those changing values in cells. But I am not gettig any hint.

Formatting of data exported to excel file

I have exported data from a text file to an excel sheet,
with the help of clipboard copy and paste.
I used PIA for this.
The exporting is done properly and the data is exported to a single column i.e in the A Column.
I want to fill my data in the rows of this column ,so that they are filled properly in the cell and I dont have to expand the A column to view complete data.
And also how can i change the font of the sheet while exporting
How is this text file created? If you have full control over its contents, I suggest using a csv ( comma-seperated-value ) file instead. You won't have control over the default font excel uses but it would fulfill your requirement of having the data populate multiple columns.
Outside of using csv file to handle this data, I suggest you look into exporting it into an excel document directly, you would have full control over look and the font used for the contents.

Categories