I am not sure if there is such a thing in Excel (xlsx) file, but if you see the screenshot
I can type in certain format of value what is displayed in cell is different from formula bar.
But if I use ClosedXml to create Excel,
currentCell.Value = "1-Jan-2017";
currentCell.DataType = XLCellValues.DateTime;
The file generated by the code looks like (just see the last cell)
Is there a way I can use ClosedXml to achieve what I need? Our business person likes to see the value "1-Jan-2017".
That format seems to be number 15 from the predefined date formats in Excel (see here). You can use the following to set it
currentCell.Style.DateFormat.SetNumberFormatId(15);
For other (not predefined) formats you can also use something like
currentCell.Style.DateFormat.SetDateFormat("d-mmm-yy");
Related
I collect various data in time plots. If I copy the timeplot data and then paste it into Excel, the number format is often wrong. For example, I often get a date like Aug 94 instead of the actual number from the TimePlot. Unfortunately, I can't easily format this date into a number either, since the formatted number does not match the actual number from the timeplot. If I format the date in the same format as the number above and below, then I get the number 34547. However, this number does not correspond to the actual number of the TimePlot. Anyone know how I can prevent this problem?
You can only solve this on the Excel side, AnyLogic provides the raw data for you. Excel then interprets stuff. You can test it by pasting the chart raw data into a txt or csv file.
So either fix your Excel settings or paste into a csv, then into an xlsx.
Or better still: Do not manually paste at all. Instead, write your model results into the AnyLogic database and export to Excel from there: this takes away a lot of the pain for you. Check the example models to learn how to do that.
This is not AnyLogic question, rather an Excel & computer formatting problem. One way of resolving this is changing computer's date and time settings.
Another way is to save your output at txt file in AnyLogic. Replace all . with ,. Then open empty Excel, select Text format for the columns. Copy-paste from the txt file.
In Excel there are a few options
when you paste use paste as text only option
But this does not always work as Excel will still try to format the stuff for you
Use the Paste Special option and then choose text
Also possible this will not work, based on your Excel settings.
Paste using the text import wizard
(This works for me without fail)
On step 2 choose tab delimited
On step 3 choose Column format as text for every column (you need to select them in the little diagram below)
You will then see the data exactly as it came from AnyLogic. See the example below where I purposefully imported some text which has something that Excel will think is a date. You will now be able to see what in your data made Excel thing your data needed to be formatted the way it is and then you can fix it. (post a new question if you struggle with this conversion)
But as noted by other answers first prize is to write all the important data to external files. But I know that even I sometimes want to export data from a chart and review it in Excel. Option 3 works for me everytime
Helo, I have report, where I show some photos. However, if the report is generated as Excel output, I don't want to have the photos there, because the size of generated file is too big in that case.
Because of that, I want to have those columns empty, if the output format is Excel (or, even not HTML would work). I have tried to do it through excel:formula in Attributes section of the cell, but it did not work (I guess, it is because its the formula of that excel cell.
I have also tried to create Open formula with IF statement, but wasn't able to find any way how to give it output-format as an parameter.
Is there any way how to solve this issue? How to change value of a cell depending on output-format? I been trying to find it in Pentaho documentation, but no luck so far..
Select the element you don't want to show and under size & position -> visible, add an OpenFormula by clicking the (+) and add a formula like this:
=NOT(ISEXPORTTYPE("table/excel"))
The available export types can be looked up at Master Report -> Attributes -> output-format.
When previewing as e.g. "HTML" and "Excel", the output format will automatically be set accordingly, so you can simply hit preview without changing that value every time.
I am creating a report in Business Objects Web Intelligence, and there is a requirement to format a number in millions. For example, $4,879,987.23 would be formatted as $4.9M.
I tried both a custom number format and a conditional format, and I can get it to display like I want, but when exporting to excel, I get $4.9M in the underlying data instead of $4,879,987.23 - the business I am creating this for really wants to see $4.9M, but be able to interact with the cell in Excel as if it is $4,879,987.23.
Does anyone know if there is a way to export from webi showing a ###.#M format, but using the actual number (###,###,###.##) in Excel?
Format Cell to a Number with Custom formatting as follows:
#.#,,"M"
This will convert the following value...
4321987
... within the cell to instead be displayed as...
4.3M
You can adjust slightly to your client's preferences from here.
Do note that it will round according to regular arithemetic rules.
If you do the custom formatting AFTER the data has been imported into Excel, as opposed to prior, you will not see the real number adjusted or modified in any way.
I use Open XML to load excel file,I want to extract all content of cells.First I try to get the format code and the inner text of the cell, but it seems that Open XML SDK does not provide the functionality of formatting the inner text with the format code.
The data you are looking for will most likely not be in the inner text of the Cell element.
I found this Q on SO that will answer most of your questions:
open xml excel read cell value .
It is true that OpenXml SDK does not provide a way to "convert" a value of a Cell using the format code - you need to do that conversion yourself. So you need to figure out exactly what kind of data is in your cell.
Example:
If your cell in the spreadsheet displays a date, find the value of the "value" attribute of the Cell object, convert the numeric representation of the date to a "regular date" and use the Cell style to format it the correct way.
Example:
If your cell in the spreadsheet displays a piece of text, find the index to the item in the SharedStrings-table and get the value from that.
The link above will give you pointers to do most of these things. It might seem a bit tricky at first, but you'll soon get the idea.
:-)
I'm using SSRS 2008 and I have a financial report. I would like the dollar amounts in my table to be in currency or number format when exported to Excel. Currently they end up being text.
I have trying a few things to see if its even possible. I removed the table header, didn't use the $ sign, and converted the field to decimal, but nothing seemed to work. The data in Excel always seems to be format as text.
Any suggestions?
Make sure you are using the Format string "C" but the export to excel is really a text rendering - it does not hold Excel specific attributes/qualities.
I found that instead of using a format function in the expression like:
=Format(myvar.value, "C")
Its better to not to use an expression and just change the Text Box Properties on that field. For example, I'd leave the field as:
=myvar.value
Then I would right click on the field, go to Text Box Properties, Number Sub Category/Tab, and select currency.
When doing this the results in Excel are a custom number format vs a text format.