Git Product home page Git Product logo

zexmlss's People

Contributors

avemey avatar el-strannik avatar mtwstark avatar serbod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zexmlss's Issues

Row with search/order arrows

is it possible to add the first row search/order arrows (CTRL+SHIFT+L) using TZEXMLSS library?
thanks in advance
image

Delphi 2007

Is it possible to set a cell to a unicode string value in delphi 2007 where string type is AnsiString?

MyWideString := 'сатри санҷиши юникод';
MyCell.AsString := MyWideString;

but in result xlsx MyCell will get '????? ??????? ??????'

Master не собирается в Lazarus 2.2.3 / FPC 3.2.3

При попытке скомпилировать пакет ошибки

zexml.inc(25,5) Error: Incompatible types: got "AnsiString" expected "Extended"
zexml.inc(25,5) Error: Compile time expression: Wanted Boolean but got <erroneous type> at IF or ELSEIF
zexml.inc(25,5) Error: Incompatible types: got "AnsiString" expected "Extended"
zexml.inc(25,5) Error: Compile time expression: Wanted Boolean but got <erroneous type> at IF or ELSEIF

исправление

// Archivers for Delphi, not used for Free Pascal / Lazarus
// Архиваторы для Delphi, не используются для Free Pascal / Lazarus
+++ {$IFNDEF FPC}
{ use Delphi XE2 and above }
{$if CompilerVersion >= 23.0}         // bds xe2 (2012)
  {$define XE2ZIP}
{$ifend}

и потом

{ use Synopse }
{//$define SYNZIP}
+++ {$EndIf}

// Free Pascal / Lazarus
{$IFDEF FPC}

XLSX reading creates empty ghost row after real file content

...later, iterating through the worksheet this creates unxexpected data type conversion errors.

D:\DelphiProjects\Libs\zexmlss.Vanilla\zexmlss\src\zexlsx.pas

function ZEXSLXReadSheet(var XMLSS: TZEXMLSS; var Stream: TStream; const SheetName: string; var StrArray: TStringDynArray; StrCount: integer;

This is how row counter is being maxing out, by call to this helper routine.

  //Проверить кол-во строк
  procedure CheckRow(const RowCount: integer);
  begin
    if (_currSheet.RowCount < RowCount) then
      _currSheet.RowCount := RowCount;
  end;

This sets the correct cunt already:

procedure _GetDimension();        
  ...
      if (_maxR > 0) then
        CheckRow(_maxR);

This later sets it again, thrice.

First go:

  procedure _ReadSheetData();
  ...
      if ((xml.TagName = 'row') and (xml.TagType in [TAG_TYPE_START, TAG_TYPE_CLOSED])) then
      begin
        _currCol := 0;
        s := xml.Attributes.ItemsByName['r']; //индекс строки
        if (s > '') then
          if (TryStrToInt(s, t)) then
          begin
            _currRow := t - 1;
            CheckRow(t);
          end;

This is correct.

Second source:

  procedure _ReadSheetData();
  ...
        if (xml.TagType = TAG_TYPE_CLOSED) then
        begin
          inc(_currRow);
          CheckRow(_currRow + 1);
        end;

Looks reasonable - if we have a null, empty tag like <row/> we need to uptick the counter.

Third source - copy-paste error!!!

  procedure _ReadSheetData();
  ...
      //конец строки
      if ((xml.TagName = 'row') and (xml.TagType = TAG_TYPE_END)) then
      begin
        inc(_currRow);   ---  OOOOOPS !!!!
        CheckRow(_currRow + 1);
      end;

Hey, if you do parse </row> - WHY would you increment the counter yet again???
You already did it above, don't do it again!

XMLSS: HTML Cells corruption

Берём ячейку со значением, внутри которого разные шрифты, надстрочные и подстрочные индексы, типа

  <Cell ss:StyleID="s80">
   <ss:Data ss:Type="String" xmlns="http://www.w3.org/TR/REC-html40">
   <I>
    <Font html:Color="#000000">L</Font> 
   <Sub>
    <Font html:Color="#000000">0</Font> 
    </Sub>
    <Font html:Color="#000000">– долгота осевого меридиана шестиградусной зоны [градусы];</Font> 
    </I>
    </ss:Data>
    </Cell>

Или

   <Cell ss:StyleID="s70">
   <ss:Data ss:Type="String" xmlns="http://www.w3.org/TR/REC-html40">
   <I>
   <Font html:Color="#000000">В – геодезическая широта рассматриваемого объекта</Font> 
     <Font html:Color="#FF0000">[радианы]</Font> 
     <Font html:Color="#000000">;</Font> 
     </I>
     </ss:Data>
     </Cell>

Открываем в компоненте, закрываем.... и не можем открыть в Экселе:

Ошибка XML в "Таблица"
Причина: Слишком много тегов
Файл: C:\xxxx.xml
Группа: Font
Тег: Font
Атрибут: Color
Значение: #000000

Вглядываемся - и находим там такие, ставшие вложенными структуры:

  <Cell ss:StyleID="s27">
  <ss:Data ss:Type="String" xmlns="http://www.w3.org/TR/REC-html40">
  <Font html:Color="#FF0000">
    <Font html:Color="#000000">В – геодезическая широта рассматриваемого объекта</Font> 
    [радианы] 
    </Font>
    <Font html:Color="#000000">;</Font> 
    <I /> 
    </ss:Data>
    </Cell>

    <Cell ss:StyleID="s37">
     <ss:Data ss:Type="String" xmlns="http://www.w3.org/TR/REC-html40">
     <Sub>
     <Font html:Color="#000000">
      <Font html:Color="#000000">L</Font> 
      0 
      </Font>
      </Sub>
      <Font html:Color="#000000">– долгота осевого меридиана шестиградусной зоны [градусы];</Font> 
      <I /> 
      </ss:Data>
      </Cell>

Примеры ZEPicture и TZEChart

Добрый день, очень нравится Ваша работа!
Но хотелось бы примеры работы с TZEPicture и TZEChart
Спасибо!

Спецсимволы

В модуле zsspxml есть функция CheckStrEntity(const st: ansistring; checkamp: boolean = true): ansistring;. Крайний параметр указывает, что нужно все & заменять на &amp;. Значение этого параметра выставлено по умолчанию и при вызове этой функции параметр нигде не меняется.

В итоге вот это:
formatCode="#,##0.00&quot;р.&quot;"
меняется на это:
formatCode="#,##0.00&amp;quot;р.&amp;quot;"
При открытии такого файла Excel ругается.

Как мне кажется, нужно checkamp наоборот установить в значение false по дефолту, ибо всё равно при этом запустится процедура проверки Correct_Entity, которая заменить & только там, где нужно.

Сохранение и открытие xlsx в delphi

Здравствуйте.

Что-то не понимаю как в последней версии теперь открывать файл в delphi. Раньше была функция ReadXSLX, а теперь она
{$IFDEF FPC} function ReadXLSX(var XMLSS: TZEXMLSS; FileName: string): integer; {$ENDIF}
только для FPC.

Для сохранения тоже раньше использовал SaveXmlssToXLSX, теперь она для FPC.

Incorrect reading, potentially garbage in memory

zexmlss.pas(5907,19) Hint: Local variable "fcc" does not seem to be initialized

You confused TStream.Read and TStream.ReadBuffer!

procedure TZEPicture.AssignFromStream(AStream: TStream);
var
  fcc: LongWord;
begin
  if Assigned(FDataStream) then
    FreeAndNil(FDataStream);
  FFileName := '';
  FDataStream := TMemoryStream.Create();
  AStream.Position := 0;
  // detect file type
---  AStream.Read(fcc, SizeOf(fcc));
+++  AStream.ReadBuffer(fcc, SizeOf(fcc));
  if fcc = $474E5089 then
    FFileName := '.png'
  else if fcc = $E0FFD8FF then
    FFileName := '.jpeg';
  AStream.Position := 0;
  FDataStream.CopyFrom(AStream, AStream.Size);
end;

zip inc

можешь убрать из кода инклуды для zip'a ?

все равн оони ничег оне делают, только людей пугают...

XLSX Cell border type & width

_WriteBorderItem in zexlsx.pas (line 4200)

  1. there should be check for zero-weight borderline
_border := XMLSS.Styles[StyleNum].Border[BorderNum];
s1 := '';

++ if _border.Weight > 0 then
case _border.LineStyle of
ZEContinuous:

  1. you should actually use "thin" line instead of "hair" - when you need solid (continuous) line
if _border.Weight > 0 then
case _border.LineStyle of
  ZEContinuous:
    begin
      //thin ??
      if (_border.Weight = 1) then
        s1 := 'thin'; // 'hair'
      else
      if (_border.Weight = 2) then
        s1 := 'medium'
      else
        s1 := 'thick';
    end;

Maybe hairline should go into ZEDot: section instead
xlsx_hairline_border_dotted

Avoid "If Length(string) > 0" - suboptimal

String (like Dynamic arrays) is pointer. Those lines are equivalent:

  • S := '';
  • S := nil;
  • SetLength(S, 0);

Hence condition "If Length(sss) <> 0" is not only hard to read - it is just much slower than straight "If sss <> '' "

Delphi XE2 dump:

 zsspxml.pas.2799: if result > '' then
 00701676 8B45FC           mov eax,[ebp-$04]
 00701679 833800           cmp dword ptr [eax],$00
 0070167C 0F861CFFFFFF     jbe $0070159e

 zsspxml.pas.2811: if length(result) > 0 then
 007016BF 8B45FC           mov eax,[ebp-$04]
 007016C2 8B00             mov eax,[eax]
 007016C4 8945E8           mov [ebp-$18],eax
 007016C7 8B45E8           mov eax,[ebp-$18]
 007016CA 8945E4           mov [ebp-$1c],eax
 007016CD 837DE400         cmp dword ptr [ebp-$1c],$00
 007016D1 740B             jz $007016de
 007016D3 8B45E4           mov eax,[ebp-$1c]
 007016D6 83E804           sub eax,$04
 007016D9 8B00             mov eax,[eax]
 007016DB 8945E4           mov [ebp-$1c],eax
 007016DE 837DE400         cmp dword ptr [ebp-$1c],$00
 007016E2 7E0C             jle $007016f0

скриптовая обвязка

  1. можно тебя попросить вывести скрипты в отдельную ветку, не связанную с улучшениями XLSX/ODF ?

  2. ты уверен, что pretty-log нужно использовать %H а не %T ?
    http://www.kernel.org/pub/software/scm/git/docs/git-log.html#_pretty_formats
    Мне показалось, что %T правильнее, но м.б. я не так понимаю разницу

  3. вообще это дико криво как-то, неужели линуксоиды считают это нормально, лишь каждая одна команда была простой и быстрой
    Нет чтобы объединить filter drivers и макросы pretty log

ODS export ensure string cell type

Generated ODS file might be loaded erroneously by some spreadsheets, if the string cell type is not specified. Details were probably sent by e-mail in 2018. The fix is one-liner.

  1. Open zexmlss/src/zeodfs.pas
  2. Find "ZEansistring ZEError ZEDateTime" comment.
  3. Right after it insert ss := 'string';

cell with float numbers and datetimes

Hi,
I tried TZEXMLSS with delphi 10.0.
If I create a cell of type string or int everything is ok, but with float or datetime cells I have some problems.
I tried with
MyDoc.Sheets [0] .Cell [i, j] .Data: = FloatToStr (Mytab.Fields [i] .AsFloat); MyDoc.Sheets [0] .Cell [i, j] .CellType: = ZENumber;
and
MyDoc.Sheets [0] .Cell [i, j] .Data: = DateTimeToStr (Mytab.Fields [i] .Asdatetime); MyDoc.Sheets [0] .Cell [i, j] .CellType: = ZEDateTime;
and
TZXMLSSave.From(MyDoc).Charset('utf-8', TextConverter).Save(my_name);
but
in excel date cell is empty and float cell contain a date like 30/12/1899

can you help me?

XLSX - Color - Alpha

Ты везде добавляешь '00' + HTMLColor

На самом деле надо добавлять 'ff'

И по хорошему при чтении надо проверять, что там в точности 8 символов, потому что по %%% стандарту - это до 4 байтов ограниченный w3c xmlBinary (ещё один %%% стандарт).

Кстати, может слегка плюнуть на старую Delphi и использовать TAlphaColor? И UITypes.TColorRec / UITypes.TAlphaColorRec чтобы с shr не трахаться?

XML entities

Сделал я поиск по & QUOT ; и получается у тебя есть три несвязанных места

  1. СorrectStrForXML zexmlss.pas line 940
  2. ZEReplaceEntity zesavecommon.pas
  3. CheckStrEntity zsspxml.pas

Хрень получается...

По хорошему нужен один список замен и РЯДОМ расположенные функции перевода в обе стороны.

А нарвался я на это, когда добавил сохранение NumberFormat в XML SS

И вот тут фокус просто прекрасный... когда сохраняем - делаем подмену на entity
А когда читаем - не делаем!
А при сохранение делаем подмену поверх подмены.

Хрень какая-то, похоже у тебя парсер несимметричный относительно подмен :-/

ZipTV library XLSX/ODS generator

Using for XLSX export is problematic - there is a rather nasty bug in the ZipTV library, and the vendor is loooong gone west.

May 2019 was last time their site worked, and see what Delphi versions they ever knew...

However, i already made it in an attempt to add support for a legacy Delphi 5 project, so... Let it be merged into upstream.

This code would be useful for developers:

  • ...having ZipTV with sources, so they can fix ZipTV bug as described
  • ...only generating .ODS files which, probably, are not affected by ZipTV
  • ...having some newer than me ZipTV versions (slim chance but MAYBE it was fixed)
  • ...just needing a template to support any other disk-only TStream-never library.

This code is dependent upon my quick fix for Delphi 5 compilation

zeZippyTV.zip

XML-SS (XML-2003 Table) file created by OpenOffice 4.1.7 can not be read.

The problem is in XML parser lacking concept of XML namespaces, and then XML consumers forgetting to ignore namespaces either.

Fast fix below.

0001-OpenOffice.org-XML-2003-read.patch.txt

This is against my internal repo, which predates yours, so you can not apply it by means of Git, but pre-Git patch utilities should do.

Этот патч из моего репозитория, который был раньше твоего и у него дугой корень.
Git'ом ты его вряд ли применишь, нужно использовать вне-Git'овый (до-Git'овый) patch, либо руками.

Версия для Lazarus не предвидется?

Доброе время суток,

пользую ZColorStringGrid на дельфях, сейчас есть проект на Лазаре где хотелось бы его использовать. Может адаптируете? Желательно чтоб и под линукс с маком можно было скомпилить.

Спасибо

Delphi 7 compatibility

Hi,
I'm trying the numberformats-branch and in unit "zeodfs.pas" the procedure _ReadAutoFilter() contains two lines with calls to ReplaceStr(). I think it's better to use AnsiReplaceStr(), that way the code compiles in Delphi 7 too. Also, from what I can tell ReplaceStr() itself calls AnsiReplaceStr() with the same parameters. It probably won't result in a huge speed improvement though. 😉

Abbrevia zeZippy bridge

Тут смотри какая штука выходит

  1. в случае ошибки желательно за собой все подчистить, не плодить мусор

  2. но библиотеки делятся на два типа. Одни запускают сжатие при добавлении каждого стрима (в особо запущенном случае - асинхронно и одельным потоком, как ZipMaster, но вроде ZM и сериализует тоже, по крайней мере вроде на пятки сам себе ещё не наступал), другие эти стримы накапливают как "полётное задание", а реально отрабатывают по финальной отмашке.
    2.1) Стримы после добавления не нужны, только память забивают
    2.2) Стримы нужно хранить до фнального сжатия, и удалять только потом
    2.1) При ошибке на диске уже лежит недобитый ZIP и его надо добить. Зато стримы уже должны быть освобождены по идее.
    2.2) При ошибке на диске просто ничего не успевает создаться, и DoAbortAndDelete;
    должна удалить файл, а для этого или надо удалить объект-зипппер, или скомандовать ему закрыть файл. Ну и опять же стримы поубивать, но это базовый класс должен сделать.

К какому типу относится Аббревия я не знаю, это тебе наблюдать.
А Глобалдьная закрывашка у тебя - да, пустой метод.
Пусть лучше будет 10 пустых методов, чем кто-то где-то забудет метод определить и будет тупить "почемуничегонеработает"

Типы ячеек

При создании новой ячейки TZCell через Create тип по умолчанию ставится ZEString, а при чтении файла с диска (созданного из Excel) тип по умолчанию (для всех ячеек, для которых тип не указан явно) ставится ZENumber. Это чем-то обусловлено?

Мне кажется правильнее будет при чтении тоже ставить ZEString или, как вариант, добавить настройку с дефолтным типом и при чтении ориентироваться на него.

Могу поправить сам, но хотелось бы знать Ваше мнение.

XLSX - prevent Cell comments from go missing

Excel 2010 just discards comments lacking authorId (but tolerates empty-string Author)
Excel then throws error like: Удаленный компонент: часть /xl/comments1.xml с ошибкой XML. (Примечания) Ошибка загрузки. Строка 2, столбец 139.

This is against my internal repo, which predates yours, so you can not apply it by means of Git, but pre-Git patch utilities should do.

0001-xlsx-export-fix-adding-cell-comments-from-internal-f.patch.txt

Этот патч из моего репозитория, который был раньше твоего и у него дугой корень.
Git'ом ты его вряд ли применишь, нужно использовать вне-Git'овый (до-Git'овый) patch, либо руками.

Не правильно работают границы на объединенных ячейках

И так, если для объединенной ячейки поставить к примеру толстую рамку вокруг (без пересечения), то при считывании файла а потом его сохранения получаем такой баг.
Гриница остается слева и вверху, а низ и правая сторона остаются без границы.
image

Это все происходит из-за того, то для объединенной области всем ячейкам присваивается стиль верхней левой ячейки. Но так как у этой верхней левой ячейки стиль не содержит границ снизу и справа, получаем такой эффект.

вся проблема кроется вот в этом куске кода:

        _in_merge_not_top := false;
        k := _sheet.MergeCells.InMergeRange(j, i);
        if (k >= 0) then
          _in_merge_not_top := _sheet.MergeCells.InLeftTopCorner(j, i) < 0;

        if (_in_merge_not_top) then
        begin
          k1 := _sheet.MergeCells.Items[k].Left;
          k2 := _sheet.MergeCells.Items[k].top;
        end
        else
        begin
          k1 := j;
          k2 := i;
        end;

        if (_sheet.Cell[k1, k2].CellStyle >= -1) and (_sheet.Cell[k1, k2].CellStyle < XMLSS.Styles.Count) then
          s := IntToStr(_sheet.Cell[k1, k2].CellStyle + 1)
        else
          s := '0';
        _xml.Attributes.Add('s', s, false);

если его заменить на этот, все заработает:

        if (_sheet.Cell[j, i].CellStyle >= -1) and (_sheet.Cell[j, i].CellStyle < XMLSS.Styles.Count) then
          s := IntToStr(_sheet.Cell[j, i].CellStyle + 1)
        else
          s := '0';
        _xml.Attributes.Add('s', s, false);

Суть в том, что у ячеек должны оставаться свои же стили, ничего подменять не надо, так делает и сам офис.

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.