Git Product home page Git Product logo

Comments (10)

Avemey avatar Avemey commented on June 29, 2024

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.

soft-user avatar soft-user commented on June 29, 2024

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.

Avemey avatar Avemey commented on June 29, 2024

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.

jonyrh avatar jonyrh commented on June 29, 2024

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.

Avemey avatar Avemey commented on June 29, 2024

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.

jonyrh avatar jonyrh commented on June 29, 2024

Я пытаюсь разделить число на разряды:

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.

Avemey avatar Avemey commented on June 29, 2024

Вообще-то это странно, т.к. в данном случае должно хватать формата "# ##0". И у меня даже excel 2003 с патчами разделяет нормально.
Как вариант - если уж экселю что-то не нравится, можно попробовать: "###\ ###\ ###\ ###\ ###\ ##0".
Ну и для отрицательных чисел можно задействовать формат, чтобы минус не отъезжал далеко:
# ###;"-"# ###;0

from zexmlss.

jonyrh avatar jonyrh commented on June 29, 2024

Все равно не правильно проставляет формат, использовал несколько вариантов:
1) # ##0 - показывает только разряд до тысячи
Снимок 1
2) ###\ ###\ ###\ ##0 или ### ### ### ##0 - Более похож на правду, но числа не по центру ячейки, впереди добавляются пробелы.
Снимок 2
3) # ###;"-"# ###;0 - как и в первом варианте
Снимок 3

Как видно, откуда то добавляются обратные слэши, даже если их не использовать в формате... Excel 2019 все обновления...
Мини-проект тут exe-файл удалять не стал, для проверки...

from zexmlss.

jonyrh avatar jonyrh commented on June 29, 2024

Нашел правильный формат методом тыка!
Удивительно, но если вместо пробела поставить запятую, то формат будет идеальный!
#,##0 - при таком формате правильно отображается в Excel, но если этот формат применить в самом Excel, то получим, как и ожидалось, число с запятой! Костыль конечно, но хоть так работает как необходимо.
Спасибо за уделенное время!

from zexmlss.

the-Arioch avatar the-Arioch commented on June 29, 2024

This kind of questions is almost impossible to solve without

  1. Making and uploading specific sample of code
  2. Making and uploading specific resulting XLSX file
  3. 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.