Comments (10)
Hi!
It seems like you forget to use number formats. For float/datetime cells it is required to set concrete number format.
Here is example:
```
MyDoc.Styles.Count := 2;
MyDoc.Styles[0].NumberFormat := '#.###';
MyDoc.Styles[1].NumberFormat := 'YYYY.MM.DD';
MyDoc.Sheets[0].RowCount := 20;
MyDoc.Sheets[0].ColCount := 20;
MyDoc.Sheets[0].Cell[0, 0].AsDouble := 20.5;
MyDoc.Sheets[0].Cell[0, 0].CellStyle := 0;
MyDoc.Sheets[0].Cell[0, 1].AsDateTime := now();
MyDoc.Sheets[0].Cell[0, 1].CellStyle := 1;
More about number formats http://avemey.com/zexmlss/numformat.php?lang=en
from zexmlss.
Thanks.
Now is better.
Number it's ok.
for date i had always same problem.
after
MyDoc.Sheets[0].Cell[0, 1].AsDateTime := now();
MyDoc.Sheets[0].Cell[0, 1].AsDateTime
is 23/08/2019 22:58:25
but in excel is empty cell
i set
MyDoc.Sheets[0].Cell[0, 1].CellType := ZEDateTime; MyDoc.Sheets[0].Cell[0, 1].AsDateTime := now(); MyDoc.Sheets[0].Cell[0, 1].CellStyle := 1
and i try with
MyDoc.Styles[1].NumberFormat := 'YYYY.MM.DD';
and
MyDoc.Styles[1].NumberFormat := 'DD/MM/YYYY';
where am I wrong?
from zexmlss.
Can you say version of MS Office that you use?
I check this with Office 365 (last updates 2019) - it is ok, date is visible and correct.
But old ms office 2003 with installed file format converters (xlsx) not shows dates because it is very old.
Do you still use excel 2003? If yes try to use excel xml format instead of xlsx.
from zexmlss.
Hi!
What NumberFormat to use for the separation of bits?
I tryet set NumberFormat:='# ##0', but in document format "#\ ##0"
Using Office 2019 last updates, RAD 10.3.2 last updates & fixes
from zexmlss.
Hi!
What do you mean about separation of bits?
Do you need to view number cell 200051 as "200 051"?
If yes than correct number formats are both "# ##0" and "#\ ##0" because backslash ("\") followed by letter means something similar to escape sequence like in c/c++/c# strings.
For example you can not use hash (#) symbol directly in number format because it has meaning of significant digit, but using escape you can show number cell "20" as "20#" by using number format like "#\#".
Some signs required to be escaped (#, ", ') but white space is not required to be escaped.
from zexmlss.
Я пытаюсь разделить число на разряды:
tz.Styles[0].NumberFormat:='##'; - что использовать?
with tz.Sheets[0] do
begin
RowCount := 1;
ColCount := 1;
Title := 'Sheet 1';
Cell[0, 0].CellStyle := 0;
Cell[0, 0].AsInteger:=100000000;
end;
Как я только не пытался:
tz.Styles[0].NumberFormat:='### ### ### ##0'; - Даёт разделение числа на разряды, но Еxcel добавляет пробелы, и если посмотреть формат в свойствах ячейки, то он выглядит так ###\ ###\ ###\ ##0
Если так:
tz.Styles[0].NumberFormat:='#.##0'; - то результат есть, но только до сотых, число больше 1000 уже не делится на разряды...
Подскажите, пожалуйста, какой формат использовать, чтобы число делилось на разряды так 999 999 999 999 и если число ноль, то ставилась одна цифра 0.
from zexmlss.
Вообще-то это странно, т.к. в данном случае должно хватать формата "# ##0". И у меня даже excel 2003 с патчами разделяет нормально.
Как вариант - если уж экселю что-то не нравится, можно попробовать: "###\ ###\ ###\ ###\ ###\ ##0".
Ну и для отрицательных чисел можно задействовать формат, чтобы минус не отъезжал далеко:
# ###;"-"# ###;0
from zexmlss.
Все равно не правильно проставляет формат, использовал несколько вариантов:
1) # ##0 - показывает только разряд до тысячи
2) ###\ ###\ ###\ ##0 или ### ### ### ##0 - Более похож на правду, но числа не по центру ячейки, впереди добавляются пробелы.
3) # ###;"-"# ###;0 - как и в первом варианте
Как видно, откуда то добавляются обратные слэши, даже если их не использовать в формате... Excel 2019 все обновления...
Мини-проект тут exe-файл удалять не стал, для проверки...
from zexmlss.
Нашел правильный формат методом тыка!
Удивительно, но если вместо пробела поставить запятую, то формат будет идеальный!
#,##0 - при таком формате правильно отображается в Excel, но если этот формат применить в самом Excel, то получим, как и ожидалось, число с запятой! Костыль конечно, но хоть так работает как необходимо.
Спасибо за уделенное время!
from zexmlss.
This kind of questions is almost impossible to solve without
- Making and uploading specific sample of code
- Making and uploading specific resulting XLSX file
- At least reporting Delphi version and Windows codepage, but better to report all the contents of
TFormatSettings
global variable (for example Delphi Xe2 has RTL bug and corrupts the variable on Russian Windows).
There is probably some quirk inside generated XLSX, and why not - i found and documented few others back in 2013 - which can not properly be fixed without samples.
Otherwise it will always be just randomly finding ad hoc work-arounds, that only can work with one specific project, and then next another projects would have to find different hacks.
from zexmlss.
Related Issues (20)
- Можно написать команду немножко проще
- Версия для Lazarus не предвидется?
- Примеры ZEPicture и TZEChart HOT 1
- XLSX - Color - Alpha HOT 1
- Не правильно работают границы на объединенных ячейках
- Delphi 2007 HOT 4
- XLSX - prevent Cell comments from go missing
- XML-SS (XML-2003 Table) file created by OpenOffice 4.1.7 can not be read.
- ODS export ensure string cell type HOT 1
- FPC 3.2+ incompability - compiler error with addref / release
- What is the correct place to downloaded newest source + all fixes?
- Out of memory problem HOT 2
- sysd7 ??? Compiling in Delphi 5 HOT 2
- ZipTV library XLSX/ODS generator
- Master не собирается в Lazarus 2.2.3 / FPC 3.2.3 HOT 4
- Incorrect reading, potentially garbage in memory
- XLSX reading creates empty ghost row after real file content HOT 2
- Delphi2010 install error
- Row with search/order arrows
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zexmlss.