Maj 2018 Krajowe zatrudnienie w pracy i szacunki wynagrodzeń Stany Zjednoczone Szacunki te są obliczane na podstawie danych zebranych od pracodawców we wszystkich sektorach przemysłu w obszarach metropolitalnych i niemetropolitycznych w każdym stanie i Dystrykcie Kolumbii. Dodatkowe informacje, w tym wynagrodzenie godzinowe i roczne 10, 25, 75 i 90 percentyla oraz względny błąd standardowy procent zatrudnienia, są dostępne w pobieralnym pliku XLS. Główne grupy zawodowe (Uwaga - kliknięcie linku spowoduje przewinięcie strony do grupy zawodowej): Aby posortować tę tabelę według innej kolumny, kliknij nagłówek kolumny Tytuł zawodu (kliknij na tytuł zawodu, aby zobaczyć jego profil) (1) Szacunki dotyczące szczegółowych zawodów nie sumują się do sum, ponieważ sumy obejmują zawody, których nie pokazano oddzielnie. Szacunki nie obejmują osób samozatrudnionych. (2) Roczne wynagrodzenie obliczono, mnożąc średnie wynagrodzenie godzinowe przez liczbę pełnych godzin pracy w pełnym wymiarze godzin wynoszącą 2080 godzin w przypadku zawodów, w których nie opublikowano stawki godzinowej, roczne wynagrodzenie obliczono bezpośrednio na podstawie zgłoszonego wynagrodzenia. dane z ankiety. (3) Względny błąd standardowy (RSE) jest miarą wiarygodności statystyki ankiety. Im mniejszy jest względny błąd standardowy, tym dokładniejsza jest ocena. (4) Płace za niektóre zawody, które zazwyczaj nie pracują przez cały rok, w pełnym wymiarze godzin, są zgłaszane albo jako stawki godzinowe, albo roczne, w zależności od tego, jak zwykle są płacone. (5) Ta płaca jest równa lub większa niż 90,00 na godzinę lub 187 200 na rok. Ostatnia modyfikowana data: 30 marca 2018 r. Poleć tę stronę za pomocą: Facebook Twitter LinkedInOhio University Heritage College of Osteopathic Medicine Nauka poprzez opiekę Każdego roku nasi uczniowie rejestrują ponad 4500 godzin wolontariatu w lokalnych szkołach, klinikach i innych miejscach społeczności. Uzyskują bezpośredni wgląd w podstawową opiekę i doświadczają różnicy, jaką mogą wyrządzić jednostkom i całemu społeczeństwu. Obsługa potrzebujących sąsiadów Dobrze wyszkolona służba zdrowia, niedawno rozbudowana Klinika Dziedzictwa Społecznego jest otwarta dla mieszkańców południowego Ohio, którzy najbardziej potrzebują opieki. Klinika zapewnia bezpłatne, tanie pokazy zdrowotne, szczepienia, egzaminy, leczenie cukrzycy i inne specjalne usługi. Aby napisać ciąg, sformatowany ciąg, liczbę i formułę do pierwszego arkusza roboczego w skoroszycie programu Excel o nazwie perl. xlsx: The Moduł Excel :: Writer :: XLSX może być użyty do utworzenia pliku Excel w formacie XLSX 2007. Format XLSX to format Office Open XML (OOXML) używany przez program Excel 2007 i nowsze. Do skoroszytu można dodać wiele arkuszy roboczych, a formatowanie można zastosować do komórek. Tekst, liczby i formuły można zapisywać w komórkach. Tego modułu nie można jeszcze użyć do zapisu w istniejącym pliku Excel XLSX. Excel :: Writer :: XLSX używa tego samego interfejsu co moduł Arkusz kalkulacyjny :: WriteExcel, który tworzy plik Excel w binarnym formacie XLS. Excel :: Writer :: XLSX obsługuje wszystkie funkcje arkusza kalkulacyjnego :: WriteExcel, aw niektórych przypadkach ma większą funkcjonalność. Aby uzyskać więcej informacji, zobacz artykuł 34 Kompatybilność z arkuszem kalkulacyjnym :: WriteExcel34. Główną zaletą formatu XLSX w formacie XLS jest to, że pozwala on na większą liczbę wierszy i kolumn w arkuszu. Format pliku XLSX generuje również znacznie mniejsze pliki niż format pliku XLS. Excel :: Writer :: XLSX stara się zapewnić interfejs do tak wielu funkcji Excel39, jak to możliwe. W rezultacie do interfejsu dołączono wiele dokumentacji i na pierwszy rzut oka trudno jest zobaczyć, co jest ważne, a co nie. Tak więc dla tych z was, którzy wolą najpierw zmontować meble Ikea, a następnie przeczytać instrukcje, oto trzy proste kroki: 1. Utwórz nowy skoroszyt programu Excel (to znaczy plik) za pomocą nowego (). 2. Dodaj arkusz do nowego skoroszytu za pomocą addworksheet (). 3. Napisz do arkusza kalkulacyjnego za pomocą funkcji write (). Spowoduje to utworzenie pliku Excel zwanego perl. xlsx z pojedynczym arkuszem roboczym i tekstem 39Hi Excel39 w odpowiedniej komórce. I to jest to. Okay, więc jest tak naprawdę zerowy krok, ale użycie modułu jest oczywiste. Istnieje wiele przykładów związanych z dystrybucją i których możesz użyć, aby zacząć. Patrz: 34EXAMPLES34. Ci z was, którzy najpierw przeczytają instrukcję i złożą meble, będą wiedzieli, jak postępować. -) Moduł Excel :: Writer :: XLSX zapewnia obiektowy interfejs do nowego skoroszytu programu Excel. Następujące metody są dostępne w nowym skoroszycie. Jeśli nie jesteś zaznajomiony z interfejsami zorientowanymi obiektowo lub sposobem, w jaki są one implementowane w Perlu, spójrz na perlobj i perltoot w głównej dokumentacji Perla. Nowy skoroszyt programu Excel jest tworzony przy użyciu konstruktora new (), który akceptuje nazwę pliku lub uchwyt pliku jako parametr. Poniższy przykład tworzy nowy plik programu Excel na podstawie nazwy pliku: Oto kilka innych przykładów użycia new () z nazwami plików: Dwa ostatnie przykłady pokazują, jak utworzyć plik w systemie DOS lub Windows, w którym konieczne jest wyjście z separatora katalogu lub użyć pojedynczych cudzysłowów, aby upewnić się, że nie jest interpolowana. Aby uzyskać więcej informacji, patrz: perlfaq5: Dlaczego nie mogę używać 34C: tempfoo34 w ścieżkach DOS. Zaleca się, aby nazwa pliku korzystała z rozszerzenia. xlsx, a nie. xls, ponieważ ta ostatnia powoduje ostrzeżenie Excela w przypadku korzystania z formatu XLSX. Konstruktor new () zwraca obiekt Excel :: Writer :: XLSX, którego można użyć do dodania arkuszy roboczych i przechowywania danych. Należy zauważyć, że chociaż moje nie jest specjalnie wymagane, określa zakres nowej zmiennej skoroszytu i, w większości przypadków, zapewnia prawidłowe zamknięcie skoroszytu bez jawnego wywoływania metody close (). Jeśli nie można utworzyć pliku, z powodu uprawnień do pliku lub z innego powodu, new zwróci undef. Dlatego dobrą praktyką jest sprawdzenie wartości zwracanej nowej przed kontynuowaniem. Jak zwykle zmienna Perla zostanie ustawiona, jeśli wystąpi błąd tworzenia pliku. Zobaczysz także jeden z komunikatów ostrzegawczych wyszczególnionych w 34DIAGNOSTICS34: Możesz również przekazać prawidłową funkcję filehandle do konstruktora new (). Na przykład w programie CGI możesz zrobić coś takiego: Wymaganie dla binmode () zostało wyjaśnione poniżej. Zobacz także program cgi. pl w katalogu przykładów dystrybucji. W programach modperl, gdzie będziesz musiał zrobić coś takiego: Zobacz także programy modperl1.pl i modperl2.pl w katalogu przykładów dystrybucji. Uchwyty plików mogą być również przydatne, jeśli chcesz przesłać strumieniowo plik Excel przez gniazdo lub jeśli chcesz przechowywać plik Excel w skalarnym. Na przykład tutaj jest sposób zapisu pliku Excel na skalar: Zobacz także programy writetoscalar. pl i filehandle. pl w katalogu przykładów dystrybucji. Uwaga na temat wymagania dla binmode (). Plik Excel składa się z danych binarnych. Dlatego, jeśli używasz filehandle, powinieneś upewnić się, że binmode () to przed przekazaniem go do new (). Powinieneś to zrobić bez względu na to, czy korzystasz z platformy Windows, czy nie. Nie musisz się martwić o binmode (), jeśli używasz nazw plików zamiast uchwytów plików. Program Excel :: Writer :: XLSX wykonuje wewnętrznie binmode (), gdy konwertuje nazwę pliku na uchwyt pliku. Aby uzyskać więcej informacji o binmode (), zobacz perlfunc i perlopentut w głównej dokumentacji Perla. Co najmniej jeden arkusz roboczy powinien zostać dodany do nowego skoroszytu. Arkusz roboczy służy do zapisywania danych w komórkach: jeśli nazwa arkusza nie zostanie określona, zostanie zastosowana domyślna konwencja programu Excel, np. Arkusz1, Arkusz2 itd. Nazwa arkusza kalkulacyjnego musi być poprawną nazwą arkusza programu Excel, tzn. Nie może zawierać żadnego z następujących znaków ,. . i musi mieć mniej niż 32 znaki. Ponadto nie można używać tej samej, nierozróżniającej wielkości liter, nazwy arkuszy dla więcej niż jednego arkusza roboczego. Metody addformat () można użyć do utworzenia nowych obiektów Format, które są używane do zastosowania formatowania w komórce. Możesz zdefiniować właściwości w czasie tworzenia poprzez skrót wartości właściwości lub później za pomocą wywołań metod. Zobacz sekcję 34CELL FORMATTING34, aby uzyskać więcej informacji o właściwościach formatu i sposobie ich ustawiania. Ta metoda służy do tworzenia nowego wykresu jako samodzielnego arkusza roboczego (ustawienie domyślne) lub jako obiektu osadzalnego, który można wstawić do arkusza roboczego za pomocą metody arkusza roboczego Insertchart (). Właściwości, które można ustawić: Jest to wymagany parametr. Określa rodzaj wykresu, który zostanie utworzony. Dostępne typy: Służy do definiowania podtypu wykresu, jeśli jest dostępny. Zobacz dokumentację Excel :: Writer :: XLSX :: Chart, aby zobaczyć listę dostępnych podtypów wykresów. Ustaw nazwę arkusza wykresu. Właściwość name jest opcjonalna i jeśli nie zostanie podana, domyślnie będzie to Chart1. n. Nazwa musi być poprawną nazwą arkusza programu Excel. Zobacz addworksheet (), aby dowiedzieć się więcej o poprawnych nazwach arkuszy. Właściwość name można pominąć w przypadku wykresów osadzonych. Określa, że obiekt wykresu zostanie wstawiony do arkusza roboczego za pomocą metody arkusza roboczego Insertchart (). Błędem jest wstawienie wykresu, który nie zawiera tej flagi. Zobacz Excel :: Writer :: XLSX :: Chart, aby dowiedzieć się, jak skonfigurować obiekt wykresu po jego utworzeniu. Zobacz także programy chart. pl w katalogu przykładów dystrybucji. Metody addshape () można używać do tworzenia nowych kształtów, które można wstawiać do arkusza roboczego. Możesz zdefiniować właściwości w czasie tworzenia poprzez skrót wartości właściwości lub później za pomocą wywołań metod. Zobacz Excel :: Writer :: XLSX :: Shape, aby dowiedzieć się, jak skonfigurować obiekt kształtu po jego utworzeniu. Zobacz także programy shape. pl w katalogu przykładów dystrybucji. Metody addvbaproject () można użyć do dodania makr lub funkcji do pliku Excel :: Writer :: XLSX przy użyciu binarnego pliku projektu VBA, który został wyodrębniony z istniejącego pliku Excel xlsm. Dostarczone narzędzie extractvba może zostać użyte do wyodrębnienia wymaganego pliku vbaProject. bin z istniejącego pliku Excel: Makra można powiązać z przyciskami za pomocą metody insertbutton () arkusza roboczego (szczegóły w sekcji 34WORKSHEET METHODS34): Uwaga, program Excel używa pliku rozszerzenie xlsm zamiast xlsx dla plików zawierających makra. Wskazane jest przestrzeganie tej samej konwencji. Metody setvbaname () można użyć do ustawienia nazwy kodowej VBA dla skoroszytu. Czasem jest to wymagane, gdy makro vbaProject zawarte w addvbaproject () odnosi się do skoroszytu. Domyślna nazwa Excel VBA ThisWorkbook jest używana, jeśli określono zdefiniowaną przez użytkownika nazwę isn39t. Zobacz także 34WORKING WITH VBA MACROS34. Zwykle plik programu Excel zostanie zamknięty automatycznie po zakończeniu programu lub gdy obiekt skoroszytu wykracza poza zakres, jednak metoda close () może zostać użyta do jawnego zamknięcia pliku Excel. Wymagane jest jawne zamknięcie (), jeśli plik musi zostać zamknięty przed wykonaniem jakiejś zewnętrznej akcji, na przykład skopiowaniem go, odczytaniem jego rozmiaru lub dołączeniem do wiadomości e-mail. Ponadto funkcja close () może być wymagana, aby uniemożliwić sortownikowi śmieci perl39 pozbywanie się skoroszytu, arkusza roboczego i formatów w niewłaściwej kolejności. Sytuacje, w których może się to zdarzyć, to: Jeśli moja () nie została użyta do zadeklarowania zakresu zmiennej skoroszytu utworzonej za pomocą funkcji new (). Jeśli nowa (). Metody addworksheet () lub addformat () wywoływane są w podprogramach. Powodem tego jest to, że Excel :: Writer :: XLSX opiera się na mechanizmie Perl39s DESTROY, aby wywołać metody destruktora w określonej sekwencji. Nie może się tak zdarzyć w przypadkach, gdy zmienne ze skoroszytu, arkusza roboczego i formatu nie mają zastosowania leksykalnego lub mają inne zakresy leksykalne. Ogólnie, jeśli utworzysz plik o rozmiarze 0 bajtów lub nie uda ci się utworzyć pliku, musisz wywołać metodę close (). Zwracana wartość close () jest taka sama, jak zwracana przez perl, gdy zamyka plik utworzony przez new (). Pozwala to na obsługę warunków błędu w zwykły sposób: Metoda setize () może być używana do ustawiania rozmiaru okna skoroszytu. Rozmiar okna programu Excel został użyty w programie Excel 2007 do zdefiniowania szerokości i wysokości okna skoroszytu w ramach interfejsu wielu dokumentów (MDI). W późniejszych wersjach programu Excel dla systemu Windows ten interfejs został usunięty. Ta metoda jest przydatna tylko przy ustawianiu rozmiaru okna w programie Excel 2017 dla komputerów Mac. Jednostki są pikselami, a domyślny rozmiar to 1073 x 644. Uwaga: to nie jest równoznaczne z rozmiarem pikseli programu Excel dla komputerów Mac, ponieważ jest oparte na oryginalnym rozmiarze. Excel 2007 dla rozmiaru Windows. Metodą setproperties można użyć do ustawienia właściwości dokumentu pliku Excel utworzonego przez program Excel :: Writer :: XLSX. Te właściwości są widoczne, gdy korzystasz z opcji Button Button -62 Prepare -62 Properties w programie Excel i są one również dostępne dla aplikacji zewnętrznych, które odczytują lub indeksują pliki systemu Windows. Właściwości powinny być przekazywane w formacie mieszającym w następujący sposób: Właściwości, które można ustawić są: Zobacz także program properties. pl w katalogu przykładów dystrybucji. Metody setcustomproperty można użyć do ustawienia jednej z wielu niestandardowych właściwości dokumentu, które nie są objęte powyższą metodą setproperties (). Te właściwości są widoczne po użyciu przycisku Office Button -62 Opcja -62 Właściwości -62 Właściwości zaawansowane -62 Opcja niestandardowa w programie Excel i są również dostępne dla aplikacji zewnętrznych, które odczytują lub indeksują pliki systemu Windows. Metoda setcustomproperty przyjmuje 3 parametry: Gdzie dostępne są typy: Daty powinny być według ISO8601 rrrr-mm-ddThh: mm: Format daty ss. sssZ w czasie Zulu, jak pokazano powyżej. Typy tekstu i liczb są opcjonalne, ponieważ zwykle można je wywnioskować z danych: parametry nazwy i wartości są ograniczone do 255 znaków w programie Excel. Ta metoda służy do zdefiniowania nazwy, która może być używana do reprezentowania wartości, pojedynczej komórki lub zakresu komórek w skoroszycie. Na przykład, aby ustawić nazwę globalnej księgi: Możliwe jest również zdefiniowanie nazwy arkusza lokalnego przez prefiksowanie nazwy z nazwą arkusza za pomocą składni nazwa_zestawu nazwaprzypisanej: Jeśli nazwa arkusza zawiera spacje lub znaki specjalne, należy ją ująć w pojedyncze cytaty, tak jak w programie Excel: Zobacz program definedname. pl w katalogu przykładów dystrybucji. Excel :: Writer :: XLSX przechowuje dane arkusza roboczego w plikach tymczasowych przed złożeniem końcowego skoroszytu. Moduł File :: Temp służy do tworzenia plików tymczasowych. Plik :: Temp używa pliku :: Spec w celu określenia odpowiedniej lokalizacji dla tych plików, takich jak tmp lub c: windowstemp. Możesz dowiedzieć się, który katalog jest używany w twoim systemie w następujący sposób: Jeśli domyślny katalog plików tymczasowych nie jest dostępny dla twojej aplikacji lub nie zawiera wystarczającej ilości miejsca, możesz określić alternatywną lokalizację za pomocą metody settempdir (): Katalog tymczasowej plik musi istnieć, settempdir () nie utworzy nowego katalogu. Ta metoda została zachowana pod kątem kompatybilności wstecznej z arkuszem kalkulacyjnym :: WriteExcel. Programy Excel :: Writer :: XLSX nie wymagają tej metody, a kolory można określić za pomocą wartości RRGGBB w stylu Html, patrz 34WORKING WITH COLOURS34. Metoda sheets () zwraca listę lub skoroszyt arkuszy w skoroszycie. Jeśli nie zostaną przekazane żadne argumenty, metoda zwróci listę wszystkich arkuszy roboczych ze skoroszytu. Jest to przydatne, jeśli chcesz powtórzyć operację na każdym arkuszu: Możesz również określić listę plasterków, aby zwrócić jeden lub więcej obiektów arkusza roboczego: lub ponieważ wartość zwracana z arkuszy () jest odwołaniem do obiektu arkusza roboczego, możesz zapisać powyższe example as: Poniższy przykład zwraca pierwszy i ostatni arkusz w skoroszycie: Array plasterki są wyjaśnione na stronie podręcznika perldata. Funkcja getworksheetbyname () zwraca arkusz lub arkusz kalkulacyjny w skoroszycie przy użyciu nazwy arkusza: Excel przechowuje daty jako liczby rzeczywiste, gdzie część całkowita przechowuje liczbę dni od epoki, a część ułamkowa przechowuje procent dnia. Epoka może być 1900 lub 1904. Excel dla Windows używa 1900, a Excel dla komputerów Macintosh używa 1904. Jednak Excel na obu platformach będzie automatycznie konwertował pomiędzy jednym systemem a drugim. Excel :: Writer :: XLSX domyślnie zapisuje daty w formacie 1900. Jeśli chcesz to zmienić, możesz zadzwonić do metody skoroszytu set1904 (). Możesz zapytać o bieżącą wartość, wywołując metodę get1904 () ze skoroszytu. To zwraca 0 dla 1900 i 1 dla 1904. Zobacz także 34 DATY I CZAS W EXCEL34, aby uzyskać więcej informacji na temat pracy z systemem dat Excel39. Ogólnie prawdopodobnie nie będziesz musiał używać set1904 (). Metoda setoptimization () służy do włączania optymalizacji w module Excel :: Writer :: XLSX. Obecnie dostępna jest tylko jedna optymalizacja, która zmniejsza zużycie pamięci. Zauważ, że po włączeniu tej optymalizacji zapisany zostanie wiersz danych, a następnie odrzucony, gdy komórka w nowym wierszu zostanie dodana za pomocą metody write () Worksheet. Dane takie powinny być zapisywane w kolejności rzędów po włączeniu optymalizacji. Ta metoda musi zostać wywołana przed wywołaniem funkcji addworksheet (). Ustaw tryb kalkulacji dla formuł w skoroszycie. Jest to głównie przydatne w przypadku skoroszytów z powolnymi formułami, w których użytkownik ma możliwość ręcznego obliczania. Parametr mode może być jednym z następujących ciągów: Domyślny. Excel ponownie wyliczy formuły, gdy formuła lub wartość wpływająca na zmiany formuły. Obliczaj ponownie tylko formuły, gdy użytkownik tego wymaga. Zazwyczaj naciskając klawisz F9. Program Excel automatycznie ponownie obliczy formuły, z wyjątkiem tabel. Nowy arkusz roboczy jest tworzony przez wywołanie metody addworksheet () z obiektu skoroszytu: Następujące metody są dostępne w nowym arkuszu: Program Excel :: Writer :: XLSX obsługuje dwie formy notacji w celu oznaczenia położenia komórek: Zapis kolumny-kolumny i zapis A1. Notacja wiersza i kolumny używa indeksu opartego na zera dla wiersza i kolumny, podczas gdy notacja A1 wykorzystuje standardową alfanumeryczną sekwencję liter alfabetu i literę opartą na 1 wierszu. Na przykład: notacja wiersza i kolumny jest przydatna, jeśli programowo odwołujesz się do komórek: notacja A1 jest przydatna do ręcznego konfigurowania arkusza roboczego i do pracy z formułami: we wzorach i odpowiednich metodach można również użyć notacji A: A: Excel :: Writer :: XLSX :: Moduł użytkowy, który jest dołączony do dystrybucji zawiera funkcje pomocnicze do obsługi notacji A1, na przykład: Dla uproszczenia listy parametrów dla wywołań metod arkusza roboczego w kolejnych sekcjach są podane w postaci wiersza - notacja kolumnowa. We wszystkich przypadkach możliwe jest również użycie zapisu A1. Uwaga: w Excelu można również użyć notacji R1C1. Nie jest to obsługiwane przez program Excel :: Writer :: XLSX. Excel rozróżnia typy danych, takie jak łańcuchy, liczby, spacje, formuły i hiperłącza. Aby uprościć proces zapisywania danych, metoda write () działa jako ogólny alias dla kilku bardziej szczegółowych metod: Ogólna zasada jest taka, że jeśli dane wyglądają jak coś, to coś jest napisane. Oto kilka przykładów zarówno w zapisie kolumna-kolumna jak i A1: Reguła 34looks jak34 jest zdefiniowana przez wyrażenia regularne: writenumber (), jeśli token jest liczbą opartą na następującym wyrażeniu regularnym: token writestring (), jeśli ustawiono keepleadingzeros () i token jest liczba całkowita z zerami wiodącymi w oparciu o następujące wyrażenie: token writeblank (), jeśli token to undef lub pusty ciąg: undef. 3434 lub 3939. writeurl (), jeśli token jest adresem http, https, ftp lub mailto na podstawie następujących wyrażeń regularnych: token mf lub token writeurl (), jeśli token jest wewnętrznym lub zewnętrznym odnośnikiem do arkusza na podstawie następującego wyrażenia regularnego: token writeformula (), jeśli pierwszy Postać tokena to 3434. writearrayformula (), jeśli token pasuje. writerow (), jeśli token jest tablicą ref. writecol (), jeśli token jest tablicą ref tablic referencji. writestring (), jeśli nie ma zastosowania żaden z powyższych warunków. Parametr formatu jest opcjonalny. Powinien to być prawidłowy obiekt Format, zobacz 34CELL FORMATTING34: Metoda write () zignoruje puste ciągi lub niezdefiniowane tokeny, chyba że dostarczony zostanie również format. W związku z tym nie musisz martwić się o specjalną obsługę pustych lub niepoprawnych wartości w danych. Zobacz także metodę writeblank (). Jednym z problemów z metodą write () jest to, że dane czasami wyglądają jak cyfry, ale nie chcesz, aby były traktowane jako liczba. Na przykład kody pocztowe lub numery identyfikacyjne często zaczynają się od początkowego zera. Jeśli zapiszesz te dane jako liczbę, początkowe zero (y) zostaną usunięte. Możesz zmienić to domyślne zachowanie, używając metody keepleadingzeros (). Podczas gdy ta właściwość jest na miejscu, wszelkie liczby całkowite z wiodącymi zerami będą traktowane jako ciągi, a zera będą zachowane. Zobacz sekcję keepleadingzeros (), aby uzyskać pełną dyskusję na temat tego problemu. Możesz również dodać własne procedury obsługi danych do metody write (), używając metody addwritehandler (). Metoda write () będzie również obsługiwać ciągi Unicode w formacie UTF-8. Zwracane są metody zapisu: Napisz liczbę całkowitą lub zmiennoprzecinkową do komórki określonej przez wiersz i kolumnę: Zobacz notatkę dotyczącą notacji 34Cell34. Parametr formatu jest opcjonalny. Ogólnie wystarczy użyć metody write (). Uwaga . niektóre wersje programu Excel 2007 nie wyświetlają obliczonych wartości formuł napisanych przez program Excel :: Writer :: XLSX. Zastosowanie wszystkich dostępnych dodatków Service Pack do programu Excel powinno to naprawić. Napisz ciąg do komórki określonej przez wiersz i kolumnę: Maksymalny rozmiar ciągu wynosi 32767 znaków. Maksymalny segment łańcucha, który program Excel może wyświetlić w komórce, wynosi 1000. Wszystkie 32767 znaków można wyświetlić na pasku formuły. Parametr formatu jest opcjonalny. Metoda write () będzie również obsługiwać ciągi w formacie UTF-8. Zobacz także programy unicode. pl w katalogu examples dystrybucji. Ogólnie wystarczy użyć metody write (). Jednak czasami możesz chcieć użyć metody writestring () do zapisania danych wyglądających jak liczba, ale nie chcesz być traktowany jako liczba. Na przykład kody pocztowe lub numery telefonów: jeśli jednak użytkownik edytuje ten ciąg, program Excel może przekonwertować go z powrotem na numer. Aby obejść ten problem, można użyć formatu tekstowego Excel: Metoda write () służy do pisania ciągów w wielu formatach. Na przykład, aby napisać ciąg 34. Jest to pogrubienie, a to jest kursywą 34. Użyto by następujących zasad: Podstawową zasadą jest rozbicie łańcucha na fragmenty i umieszczenie obiektu formatu przed fragmentem, który chcesz sformatować. Na przykład: fragmenty String, które nie mają formatu, mają format domyślny. Na przykład przy pisaniu ciągu 34Niektórzy pogrubiony tekst34 użyłbyś pierwszego przykładu poniżej, ale byłby równoważny drugiemu: Podobnie jak w Excelu, tylko właściwości czcionki tego formatu, takie jak nazwa czcionki, styl, rozmiar, podkreślenie, kolor i efekty są stosowane do fragmentów napisów. Inne funkcje, takie jak obramowanie, tło, zawijanie tekstu i wyrównanie, muszą zostać zastosowane do komórki. Metoda writerichstring () pozwala ci to zrobić, używając ostatniego argumentu jako formatu komórki (jeśli jest to obiekt formatu). Poniższy przykład centruje bogaty ciąg w komórce: Zobacz przykład richstrings. pl w dystrybucji, by zobaczyć więcej przykładów. Podobnie jak w przypadku pisania () maksymalny rozmiar łańcucha wynosi 32767 znaków. Zobacz także notatkę o notce 34Cell34. Ta metoda zmienia domyślną obsługę liczb całkowitych z wiodącymi zerami, gdy używana jest metoda write (). Metoda write () używa wyrażeń regularnych do określenia typu danych zapisywanych w arkuszu programu Excel. Jeśli dane wyglądają jak liczba, zapisuje numer za pomocą writenumber (). Jednym z problemów związanych z tym podejściem jest to, że dane czasami wyglądają jak liczby, ale nie chcesz, aby były traktowane jako liczba. Na przykład kody pocztowe i numery identyfikacyjne często zaczynają się od zera wiodącego. Jeśli zapiszesz te dane jako liczbę, początkowe zero (y) zostaną usunięte. Jest to również domyślne zachowanie podczas ręcznego wprowadzania danych w programie Excel. Aby obejść ten problem, możesz skorzystać z jednej z trzech opcji. Napisz sformatowany numer, wpisz numer jako ciąg lub użyj metody keepleadingzeros (), aby zmienić domyślne zachowanie write (): Powyższy kod wygenerowałby arkusz roboczy wyglądający jak poniżej: Przykłady znajdują się po różnych stronach komórek ze względu na fakt, że program Excel wyświetla domyślnie łańcuchy z lewym uzasadnieniem i liczbami z odpowiednim uzasadnieniem. Możesz to zmienić, używając formatu do uzasadnienia danych, patrz 34CELL FORMATTING34. Należy zauważyć, że jeśli użytkownik edytuje dane w przykładach A3 i A4, łańcuchy powrócą do liczb. Ponownie jest to domyślne zachowanie programu Excel39. Aby tego uniknąć, możesz użyć formatu tekstowego: Właściwość keepleadingzeros () jest domyślnie wyłączona. Metoda keepleadingzeros () przyjmuje 0 lub 1 jako argument. Wartość domyślna to 1, jeśli podano argument isn39t: Zobacz także metodę addwritehandler (). Napisz pustą komórkę określoną przez wiersz i kolumnę: Ta metoda służy do dodawania formatowania do komórki, która nie zawiera ciągu ani wartości liczbowej. Excel rozróżnia komórki 34Empty34 i 34Blank34. Komórka 34Empty34 to komórka, która nie zawiera danych, podczas gdy komórka 34Blank34 jest komórką, która nie zawiera danych, ale zawiera formatowanie. W programie Excel są przechowywane komórki 34Blank34, ale ignorowane są komórki 34Empty34. W związku z tym, jeśli napiszesz pustą komórkę bez formatowania, zostanie ona zignorowana: ten pozornie nieinteresujący fakt oznacza, że możesz pisać tablice danych bez specjalnego traktowania dla undef lub pustych wartości ciągu. Metoda write () może być użyta do napisania tablicy danych 1D lub 2D za jednym razem. Jest to przydatne do konwersji wyników zapytania bazy danych do arkusza programu Excel. Musisz podać odniesienie do tablicy danych, a nie samej tablicy. Metoda write () jest następnie wywoływana dla każdego elementu danych. Na przykład: Uwaga: Dla wygody metoda write () zachowuje się w taki sam sposób jak writerow (), jeśli jest przekazywana odwołanie do tablicy. Dlatego następujące dwa wywołania metod są równoważne: Podobnie jak w przypadku wszystkich metod zapisu, parametr format jest opcjonalny. Jeśli zostanie określony format, zostanie zastosowany do wszystkich elementów tablicy danych. Odniesienia do tablicy w danych będą traktowane jak kolumny. Pozwala to na pisanie tablic 2D danych za jednym razem. Na przykład: wygeneruje arkusz roboczy w następujący sposób: Aby zapisać dane w kolejności wiersza i kolumny, odwołaj się do metody writecol () znajdującej się poniżej. Wszelkie niepoprawne wartości w danych będą ignorowane, o ile do danych nie zostanie zastosowany format, w którym to przypadku zostanie zapisana sformatowana pusta komórka. W obu przypadkach odpowiednia wartość wiersza lub kolumny będzie wciąż zwiększana. Aby dowiedzieć się więcej na temat odwołań do tablic, odwołaj się do perlref i perlreftut w głównej dokumentacji Perla. Aby dowiedzieć się więcej o tablicach 2D lub 34 listach list, zobacz perllol. Metoda writerow () zwraca pierwszy błąd napotkany podczas zapisywania elementów danych lub zero, jeśli nie napotkano żadnych błędów. Zobacz wartości zwracane opisane dla metody write () powyżej. Zobacz także program writearrays. pl w katalogu przykładów dystrybucji. Metoda writerow () umożliwia następującą idiomatyczną konwersję pliku tekstowego do pliku Excel: Metoda writecol () może być użyta do napisania tablicy danych 1D lub 2D za jednym zamachem. Jest to przydatne do konwersji wyników zapytania bazy danych do arkusza programu Excel. Musisz podać odniesienie do tablicy danych, a nie samej tablicy. Metoda write () jest następnie wywoływana dla każdego elementu danych. Na przykład: Podobnie jak w przypadku wszystkich metod zapisu, parametr format jest opcjonalny. Jeśli zostanie określony format, zostanie zastosowany do wszystkich elementów tablicy danych. Odniesienia do tablicy w danych będą traktowane jak wiersze. Pozwala to na pisanie tablic 2D danych za jednym razem. Na przykład: Wykonałby arkusz roboczy w następujący sposób: Aby zapisać dane w kolejności w wierszach, odwołaj się do metody write-to () powyżej. Wszelkie niepoprawne wartości w danych będą ignorowane, o ile do danych nie zostanie zastosowany format, w którym to przypadku zostanie zapisana sformatowana pusta komórka. W obu przypadkach odpowiednia wartość wiersza lub kolumny będzie wciąż zwiększana. Jak wspomniano powyżej, metoda write () może być używana jako synonim dla pisiterow () i writerow () obsługuje zagnieżdżone odwołania do tablicy jako kolumny. Dlatego następujące dwa wywołania metod są równoważne, chociaż bardziej jednoznaczne wywołanie metody writecol () byłoby lepsze dla łatwości obsługi: Aby dowiedzieć się więcej o odwołaniach do tablicy, odwołaj się do perlref i perlreftut w głównej dokumentacji Perla. Aby dowiedzieć się więcej o tablicach 2D lub 34 listach list, zobacz perllol. Metoda writecol () zwraca pierwszy błąd napotkany podczas zapisywania elementów danych lub zero, jeśli nie napotkano żadnych błędów. Zobacz wartości zwracane opisane dla metody write () powyżej. Zobacz także program writearrays. pl w katalogu przykładów dystrybucji. Metoda writedatetime () może zostać użyta do zapisania daty lub godziny w komórce określonej przez wiersz i kolumnę: Datestring powinien mieć następujący format: Jest to zgodne z datą ISO8601, ale należy zauważyć, że pełny zakres formatów ISO8601 nie są obsługiwane. Dopuszczalne są następujące warianty parametru datestring: Należy zwrócić uwagę, że znak T jest wymagany we wszystkich przypadkach. Data powinna zawsze mieć format. w przeciwnym razie pojawi się jako liczba, patrz 34 DATY I CZAS W EXCEL34 i 34CELL FORMATTING34. Oto typowy przykład: Prawidłowe daty powinny się mieścić w przedziale od 1900-01-01 do 9999-12-31, dla epoki 1900 i 1904-01-01 do 9999-12-31, dla epoki 1904. Podobnie jak w Excelu daty poza tymi zakresami będą zapisywane jako ciąg. Zobacz także program datetime. pl w katalogu przykładów dystrybucji. Napisz hiperłącze do adresu URL w komórce określonej przez wiersz i kolumnę. Hiperłącze składa się z dwóch elementów: widocznej etykiety i niewidocznego łącza. Widoczna etykieta jest taka sama jak link, chyba że podano alternatywną etykietę. Parametr etykiety jest opcjonalny. Etykieta jest napisana przy użyciu metody write (). Dlatego możliwe jest zapisywanie ciągów, liczb lub formuł jako etykiet. Parametr format jest również opcjonalny, jednak bez formatu link nie będzie wyglądał jak link. Sugerowany format to: Uwaga. to zachowanie różni się od arkusza kalkulacyjnego :: WriteExcel, który zapewnia domyślny format hiperlinku, jeśli użytkownik nie określił jednego parametru isn39t. Obsługiwane są cztery identyfikatory URI39 w stylu WWW:. . ftp: i mailto. Możesz wyświetlić alternatywny ciąg znaków za pomocą parametru label: Jeśli chcesz mieć inne dane komórki, takie jak liczba lub formuła, możesz zastąpić komórkę, używając innego połączenia do zapisu (): Istnieją dwa lokalne identyfikatory URI: internal: and zewnętrzny. Są one używane do hiperłączy do wewnętrznych odniesień do arkusza roboczego lub zewnętrznego skoroszytu oraz do odnośników do arkusza roboczego: Wszystkie te typy URI są rozpoznawane przez metodę write (), patrz wyżej. Referencje arkusza roboczego mają zwykle postać Arkusz1A1. Możesz również zapoznać się z zakresem arkusza za pomocą standardowej notacji Excel: Arkusz1A1: B2. W łączach zewnętrznych skoroszyt i nazwa arkusza roboczego muszą być oddzielone przez znak: zewnętrzny: Workbook. xlsxSheet1A139. Możesz także połączyć się z nazwanym zasięgiem w arkuszu docelowym. Załóżmy na przykład, że masz nazwany zakres o nazwie myname w skoroszycie c: tempfoo. xlsx, który możesz połączyć z nim w następujący sposób: Program Excel wymaga, aby nazwy arkuszy zawierające spacje lub nie alfanumeryczne były pojedynczo cytowane w następujący sposób: 39Sales Data39A1. Jeśli chcesz to zrobić w pojedynczym cudzysłowu, możesz albo uciec z pojedynczych cytatów 39, albo użyć operatora kwotowania q, jak opisano w perlop w głównej dokumentacji Perla. Łącza do plików sieciowych są również obsługiwane. MSNovell Network files normally begin with two back slashes as follows NETWORKetc. In order to generate this in a single or double quoted string you will have to escape the backslashes, 39NETWORKetc39 . If you are using double quote strings then you should be careful to escape anything that looks like a metacharacter. For more information see perlfaq5: Why can39t I use 34C:tempfoo34 in DOS paths. Finally, you can avoid most of these quoting problems by using forward slashes. These are translated internally to backslashes: Note: Excel::Writer::XLSX will escape the following characters in URLs as required by Excel: s 34 60 62 unless the URL already contains xx style escapes. In which case it is assumed that the URL was escaped correctly by the user and will by passed directly to Excel. Excel limits hyperlink links and anchorlocations to 255 characters each. Write a formula or function to the cell specified by row and column : Array formulas are also supported: See also the writearrayformula() method below. If required, it is also possible to specify the calculated value of the formula. This is occasionally necessary when working with non-Excel applications that don39t calculate the value of the formula. The calculated value is added at the end of the argument list: However, this probably isn39t something that you will ever need to do. If you do use this feature then do so with care. Write an array formula to a cell range. In Excel an array formula is a formula that performs a calculation on a set of values. It can return a single value or a range of values. An array formula is indicated by a pair of braces around the formula: . If the array formula returns a single value then the first and last parameters should be the same: It this case however it is easier to just use the writeformula() or write() methods: For array formulas that return a range of values you must specify the range that the return values will be written to: If required, it is also possible to specify the calculated value of the formula. This is occasionally necessary when working with non-Excel applications that don39t calculate the value of the formula. However, using this parameter only writes a single value to the upper left cell in the result array. For a multi-cell array formula where the results are required, the other result values can be specified by using writenumber() to write to the appropriate cell: In addition, some early versions of Excel 2007 don39t calculate the values of array formulas when they aren39t supplied. Installing the latest Office Service Pack should fix this issue. See also the arrayformula. pl program in the examples directory of the distro. Note: Array formulas are not supported by Spreadsheet::WriteExcel. Write an Excel boolean value to the cell specified by row and column : A value that is true or false using Perl39s rules will be written as an Excel boolean TRUE or FALSE value. Deprecated. This is a Spreadsheet::WriteExcel method that is no longer required by Excel::Writer::XLSX. Zobacz poniżej. Deprecated. This is a Spreadsheet::WriteExcel method that is no longer required by Excel::Writer::XLSX. In Spreadsheet::WriteExcel it was computationally expensive to write formulas since they were parsed by a recursive descent parser. The storeformula() and repeatformula() methods were used as a way of avoiding the overhead of repeated formulas by reusing a pre-parsed formula. In Excel::Writer::XLSX this is no longer necessary since it is just as quick to write a formula as it is to write a string or a number. The methods remain for backward compatibility but new Excel::Writer::XLSX programs shouldn39t use them. The writecomment() method is used to add a comment to a cell. A cell comment is indicated in Excel by a small red triangle in the upper right-hand corner of the cell. Moving the cursor over the red triangle will reveal the comment. The following example shows how to add a comment to a cell: As usual you can replace the row and column parameters with an A1 cell reference. See the note about 34Cell notation34 . The writecomment() method will also handle strings in UTF-8 format. In addition to the basic 3 argument form of writecomment() you can pass in several optional keyvalue pairs to control the format of the comment. For example: Most of these options are quite specific and in general the default comment behaves will be all that you need. However, should you need greater control over the format of the cell comment the following options are available: This option is used to indicate who is the author of the cell comment. Excel displays the author of the comment in the status bar at the bottom of the worksheet. This is usually of interest in corporate environments where several people might review and provide comments to a workbook. The default author for all cell comments can be set using the setcommentsauthor() method (see below). This option is used to make a cell comment visible when the worksheet is opened. The default behaviour in Excel is that comments are initially hidden. However, it is also possible in Excel to make individual or all comments visible. In Excel::Writer::XLSX individual comments can be made visible as follows: It is possible to make all comments in a worksheet visible using the showcomments() worksheet method (see below). Alternatively, if all of the cell comments have been made visible you can hide individual comments: This option is used to set the width of the cell comment box as a factor of the default width. This option is used to set the width of the cell comment box explicitly in pixels. This option is used to set the height of the cell comment box as a factor of the default height. This option is used to set the height of the cell comment box explicitly in pixels. This option is used to set the background colour of cell comment box. You can use one of the named colours recognised by Excel::Writer::XLSX or a Html style RRGGBB colour. See 34WORKING WITH COLOURS34 . This option is used to set the cell in which the comment will appear. By default Excel displays comments one cell to the right and one cell above the cell to which the comment relates. However, you can change this behaviour if you wish. In the following example the comment which would appear by default in cell D2 is moved to E2 . This option is used to set the row in which the comment will appear. See the startcell option above. The row is zero indexed. This option is used to set the column in which the comment will appear. See the startcell option above. The column is zero indexed. This option is used to change the x offset, in pixels, of a comment within a cell: This option is used to change the y offset, in pixels, of a comment within a cell: You can apply as many of these options as you require. Note about using options that adjust the position of the cell comment such as startcell, startrow, startcol, xoffset and yoffset . Excel only displays offset cell comments when they are displayed as 34visible34. Excel does not display hidden cells as moved when you mouse over them. Note about row height and comments . If you specify the height of a row that contains a comment then Excel::Writer::XLSX will adjust the height of the comment to maintain the default or user specified dimensions. However, the height of a row can also be adjusted automatically by Excel if the text wrap property is set or large fonts are used in the cell. This means that the height of the row is unknown to the module at run time and thus the comment box is stretched with the row. Use the setrow() method to specify the row height explicitly and avoid this problem. This method is used to make all cell comments visible when a worksheet is opened. Individual comments can be made visible using the visible parameter of the writecomment method (see above): If all of the cell comments have been made visible you can hide individual comments as follows: This method is used to set the default author of all cell comments. Individual comment authors can be set using the author parameter of the writecomment method (see above). The default comment author is an empty string, 3939. if no author is specified. This method is used to extend the Excel::Writer::XLSX write() method to handle user defined data. If you refer to the section on write() above you will see that it acts as an alias for several more specific write methods. However, it doesn39t always act in exactly the way that you would like it to. One solution is to filter the input data yourself and call the appropriate write method. Another approach is to use the addwritehandler() method to add your own automated behaviour to write() . The addwritehandler() method take two arguments, re. a regular expression to match incoming data and coderef a callback function to handle the matched data: (In the these examples the qr operator is used to quote the regular expression strings, see perlop for more details). The method is used as follows. say you wished to write 7 digit ID numbers as a string so that any leading zeros were preserved, you could do something like the following: You could also use the keepleadingzeros() method for this. Then if you call write() with an appropriate string it will be handled automatically: The callback function will receive a reference to the calling worksheet and all of the other arguments that were passed to write(). The callback will see an argument list that looks like the following: Your callback should return() the return value of the write method that was called or undef to indicate that you rejected the match and want write() to continue as normal. So for example if you wished to apply the previous filter only to ID values that occur in the first column you could modify your callback function as follows: Now, you will get different behaviour for the first column and other columns: You may add more than one handler in which case they will be called in the order that they were added. Note, the addwritehandler() method is particularly suited for handling dates. See the writehandler 1-4 programs in the examples directory for further examples. This method can be used to insert a image into a worksheet. The image can be in PNG, JPEG or BMP format. The x. y. xscale and yscale parameters are optional. The parameters x and y can be used to specify an offset from the top left hand corner of the cell specified by row and col. The offset values are in pixels. The offsets can be greater than the width or height of the underlying cell. This can be occasionally useful if you wish to align two or more images relative to the same cell. The parameters xscale and yscale can be used to scale the inserted image horizontally and vertically: Note: you must call setrow() or setcolumn() before insertimage() if you wish to change the default dimensions of any of the rows or columns that the image occupies. The height of a row can also change if you use a font that is larger than the default. This in turn will affect the scaling of your image. To avoid this you should explicitly set the height of the row using setrow() if it contains a font size that will change the row height. BMP images must be 24 bit, true colour, bitmaps. In general it is best to avoid BMP images since they aren39t compressed. This method can be used to insert a Chart object into a worksheet. The Chart must be created by the addchart() Workbook method and it must have the embedded option set. See addchart() for details on how to create the Chart object and Excel::Writer::XLSX::Chart for details on how to configure it. See also the chart. pl programs in the examples directory of the distro. The x. y. xscale and yscale parameters are optional. The parameters x and y can be used to specify an offset from the top left hand corner of the cell specified by row and col. The offset values are in pixels. The parameters xscale and yscale can be used to scale the inserted chart horizontally and vertically: This method can be used to insert a Shape object into a worksheet. The Shape must be created by the addshape() Workbook method. See addshape() for details on how to create the Shape object and Excel::Writer::XLSX::Shape for details on how to configure it. The x. y. xscale and yscale parameters are optional. The parameters x and y can be used to specify an offset from the top left hand corner of the cell specified by row and col. The offset values are in pixels. The parameters xscale and yscale can be used to scale the inserted shape horizontally and vertically: See also the shape. pl programs in the examples directory of the distro. insertbutton( row, col, ) The insertbutton() method can be used to insert an Excel form button into a worksheet. This method is generally only useful when used in conjunction with the Workbook addvbaproject() method to tie the button to a macro from an embedded VBA project: The properties of the button that can be set are: This option is used to set the macro that the button will invoke when the user clicks on it. The macro should be included using the Workbook addvbaproject() method shown above. The default macro is ButtonXClick where X is the button number. This option is used to set the caption on the button. The default is Button X where X is the button number. This option is used to set the width of the button in pixels. The default button width is 64 pixels which is the width of a default cell. This option is used to set the height of the button in pixels. The default button height is 20 pixels which is the height of a default cell. This option is used to set the width of the button as a factor of the default width. This option is used to set the height of the button as a factor of the default height. This option is used to change the x offset, in pixels, of a button within a cell: This option is used to change the y offset, in pixels, of a comment within a cell. Note: Button is the only Excel form element that is available in Excel::Writer::XLSX. Form elements represent a lot of work to implement and the underlying VML syntax isn39t very much fun. The datavalidation() method is used to construct an Excel data validation or to limit the user input to a dropdown list of values. This method contains a lot of parameters and is described in detail in a separate section 34DATA VALIDATION IN EXCEL34 . See also the datavalidate. pl program in the examples directory of the distro The conditionalformatting() method is used to add formatting to a cell or range of cells based on user defined criteria. This method contains a lot of parameters and is described in detail in a separate section 34CONDITIONAL FORMATTING IN EXCEL34 . See also the conditionalformat. pl program in the examples directory of the distro The addsparkline() worksheet method is used to add sparklines to a cell or a range of cells. This method contains a lot of parameters and is described in detail in a separate section 34SPARKLINES IN EXCEL34 . See also the sparklines1.pl and sparklines2.pl example programs in the examples directory of the distro. Note: Sparklines are a feature of Excel 2017 only. You can write them to an XLSX file that can be read by Excel 2007 but they won39t be displayed. The addtable() method is used to group a range of cells into an Excel Table. This method contains a lot of parameters and is described in detail in a separate section 34TABLES IN EXCEL34 . See also the tables. pl program in the examples directory of the distro The getname() method is used to retrieve the name of a worksheet. For example: For reasons related to the design of Excel::Writer::XLSX and to the internals of Excel there is no setname() method. The only way to set the worksheet name is via the addworksheet() method. The activate() method is used to specify which worksheet is initially visible in a multi-sheet workbook: This is similar to the Excel VBA activate method. More than one worksheet can be selected via the select() method, see below, however only one worksheet can be active. The default active worksheet is the first worksheet. The select() method is used to indicate that a worksheet is selected in a multi-sheet workbook: A selected worksheet has its tab highlighted. Selecting worksheets is a way of grouping them together so that, for example, several worksheets could be printed in one go. A worksheet that has been activated via the activate() method will also appear as selected. The hide() method is used to hide a worksheet: You may wish to hide a worksheet in order to avoid confusing a user with intermediate data or calculations. A hidden worksheet can not be activated or selected so this method is mutually exclusive with the activate() and select() methods. In addition, since the first worksheet will default to being the active worksheet, you cannot hide the first worksheet without activating another sheet: The activate() method determines which worksheet is initially selected. However, if there are a large number of worksheets the selected worksheet may not appear on the screen. To avoid this you can select which is the leftmost visible worksheet using setfirstsheet() : This method is not required very often. The default value is the first worksheet. The protect() method is used to protect a worksheet from modification: The protect() method also has the effect of enabling a cell39s locked and hidden properties if they have been set. A locked cell cannot be edited and this property is on by default for all cells. A hidden cell will display the results of a formula but not the formula itself. See the protection. pl program in the examples directory of the distro for an illustrative example and the setlocked and sethidden format methods in 34CELL FORMATTING34 . You can optionally add a password to the worksheet protection: Passing the empty string 3939 is the same as turning on protection without a password. Note, the worksheet level password in Excel provides very weak protection. It does not encrypt your data and is very easy to deactivate. Full workbook encryption is not supported by Excel::Writer::XLSX since it requires a completely different file format and would take several man months to implement. You can specify which worksheet elements you wish to protect by passing a hashref with any or all of the following keys: The default boolean values are shown above. Individual elements can be protected as follows: This method can be used to specify which cell or cells are selected in a worksheet. The most common requirement is to select a single cell, in which case lastrow and lastcol can be omitted. The active cell within a selected range is determined by the order in which first and last are specified. It is also possible to specify a cell or a range using A1 notation. See the note about 34Cell notation34 . The default cell selections is (0, 0), 39A139. This method can be used to change the default properties of a row. All parameters apart from row are optional. The most common use for this method is to change the height of a row: If you wish to set the format without changing the height you can pass undef as the height parameter: The format parameter will be applied to any cells in the row that don39t have a format. For example If you wish to define a row format in this way you should call the method before any calls to write(). Calling it afterwards will overwrite any format that was previously specified. The hidden parameter should be set to 1 if you wish to hide a row. This can be used, for example, to hide intermediary steps in a complicated calculation: The level parameter is used to set the outline level of the row. Outlines are described in 34OUTLINES AND GROUPING IN EXCEL34. Adjacent rows with the same outline level are grouped together into a single outline. The following example sets an outline level of 1 for rows 1 and 2 (zero-indexed): The hidden parameter can also be used to hide collapsed outlined rows when used in conjunction with the level parameter. For collapsed outlines you should also indicate which row has the collapsed symbol using the optional collapsed parameter. For a more complete example see the outline. pl and outlinecollapsed. pl programs in the examples directory of the distro. Excel allows up to 7 outline levels. Therefore the level parameter should be in the range 0 60 level 60 7 . This method can be used to change the default properties of a single column or a range of columns. All parameters apart from firstcol and lastcol are optional. If setcolumn() is applied to a single column the value of firstcol and lastcol should be the same. In the case where lastcol is zero it is set to the same value as firstcol . It is also possible, and generally clearer, to specify a column range using the form of A1 notation used for columns. See the note about 34Cell notation34 . The width corresponds to the column width value that is specified in Excel. It is approximately equal to the length of a string in the default font of Calibri 11. Unfortunately, there is no way to specify 34AutoFit34 for a column in the Excel file format. This feature is only available at runtime from within Excel. As usual the format parameter is optional, for additional information, see 34CELL FORMATTING34. If you wish to set the format without changing the width you can pass undef as the width parameter: The format parameter will be applied to any cells in the column that don39t have a format. For example If you wish to define a column format in this way you should call the method before any calls to write(). If you call it afterwards it won39t have any effect. A default row format takes precedence over a default column format The hidden parameter should be set to 1 if you wish to hide a column. This can be used, for example, to hide intermediary steps in a complicated calculation: The level parameter is used to set the outline level of the column. Outlines are described in 34OUTLINES AND GROUPING IN EXCEL34. Adjacent columns with the same outline level are grouped together into a single outline. The following example sets an outline level of 1 for columns B to G: The hidden parameter can also be used to hide collapsed outlined columns when used in conjunction with the level parameter. For collapsed outlines you should also indicate which row has the collapsed symbol using the optional collapsed parameter. For a more complete example see the outline. pl and outlinecollapsed. pl programs in the examples directory of the distro. Excel allows up to 7 outline levels. Therefore the level parameter should be in the range 0 60 level 60 7 . The setdefaultrow() method is used to set the limited number of default row properties allowed by Excel. These are the default height and the option to hide unused rows. The option to hide unused rows is used by Excel as an optimisation so that the user can hide a large number of rows without generating a very large file with an entry for each hidden row. See the hiderowcol. pl example program. The outlinesettings() method is used to control the appearance of outlines in Excel. Outlines are described in 34OUTLINES AND GROUPING IN EXCEL34 . The visible parameter is used to control whether or not outlines are visible. Setting this parameter to 0 will cause all outlines on the worksheet to be hidden. They can be unhidden in Excel by means of the 34Show Outline Symbols34 command button. The default setting is 1 for visible outlines. The symbolsbelow parameter is used to control whether the row outline symbol will appear above or below the outline level bar. The default setting is 1 for symbols to appear below the outline level bar. The symbolsright parameter is used to control whether the column outline symbol will appear to the left or the right of the outline level bar. The default setting is 1 for symbols to appear to the right of the outline level bar. The autostyle parameter is used to control whether the automatic outline generator in Excel uses automatic styles when creating an outline. This has no effect on a file generated by Excel::Writer::XLSX but it does have an effect on how the worksheet behaves after it is created. The default setting is 0 for 34Automatic Styles34 to be turned off. The default settings for all of these parameters correspond to Excel39s default parameters. The worksheet parameters controlled by outlinesettings() are rarely used. This method can be used to divide a worksheet into horizontal or vertical regions known as panes and to also 34freeze34 these panes so that the splitter bars are not visible. This is the same as the Window-62Freeze Panes menu command in Excel The parameters row and col are used to specify the location of the split. It should be noted that the split is specified at the top or left of a cell and that the method uses zero based indexing. Therefore to freeze the first row of a worksheet it is necessary to specify the split at row 2 (which is 1 as the zero-based index). This might lead you to think that you are using a 1 based index but this is not the case. You can set one of the row and col parameters as zero if you do not want either a vertical or horizontal split. The parameters toprow and leftcol are optional. They are used to specify the top-most or left-most visible row or column in the scrolling region of the panes. For example to freeze the first row and to have the scrolling region begin at row twenty: You cannot use A1 notation for the toprow and leftcol parameters. See also the panes. pl program in the examples directory of the distribution. This method can be used to divide a worksheet into horizontal or vertical regions known as panes. This method is different from the freezepanes() method in that the splits between the panes will be visible to the user and each pane will have its own scroll bars. The parameters y and x are used to specify the vertical and horizontal position of the split. The units for y and x are the same as those used by Excel to specify row height and column width. However, the vertical and horizontal units are different from each other. Therefore you must specify the y and x parameters in terms of the row heights and column widths that you have set or the default values which are 15 for a row and 8.43 for a column. You can set one of the y and x parameters as zero if you do not want either a vertical or horizontal split. The parameters toprow and leftcol are optional. They are used to specify the top-most or left-most visible row or column in the bottom-right pane. You cannot use A1 notation with this method. See also the freezepanes() method and the panes. pl program in the examples directory of the distribution. The mergerange() method allows you to merge cells that contain other types of alignment in addition to the merging: mergerange() writes its token argument using the worksheet write() method. Therefore it will handle numbers, strings, formulas or urls as required. If you need to specify the required write() method use the mergerangetype() method, see below. The full possibilities of this method are shown in the merge3.pl to merge6.pl programs in the examples directory of the distribution. The mergerange() method, see above, uses write() to insert the required data into to a merged range. However, there may be times where this isn39t what you require so as an alternative the mergerangetype () method allows you to specify the type of data you wish to write. For example: The type must be one of the following, which corresponds to a write() method: Any arguments after the range should be whatever the appropriate method accepts: Note, you must always pass a format object as an argument, even if it is a default format. Set the worksheet zoom factor in the range 10 60 scale 60 400 : The default zoom factor is 100. You cannot zoom to 34Selection34 because it is calculated by Excel at run-time. Note, setzoom() does not affect the scale of the printed page. For that you should use setprintscale() . The righttoleft() method is used to change the default direction of the worksheet from left-to-right, with the A1 cell in the top left, to right-to-left, with the A1 cell in the top right. This is useful when creating Arabic, Hebrew or other near or far eastern worksheets that use right-to-left as the default direction. The hidezero() method is used to hide any zero values that appear in cells. In Excel this option is found under Tools-62Options-62View. The settabcolor() method is used to change the colour of the worksheet tab. You can use one of the standard colour names provided by the Format object or a Html style RRGGBB colour. See 34WORKING WITH COLOURS34 . See the tabcolors. pl program in the examples directory of the distro. This method allows an autofilter to be added to a worksheet. An autofilter is a way of adding drop down lists to the headers of a 2D range of worksheet data. This allows users to filter the data based on simple criteria so that some data is shown and some is hidden. To add an autofilter to a worksheet: Filter conditions can be applied using the filtercolumn() or filtercolumnlist() method. See the autofilter. pl program in the examples directory of the distro for a more detailed example. The filtercolumn method can be used to filter columns in a autofilter range based on simple conditions. NOTE: It isn39t sufficient to just specify the filter condition. You must also hide any rows that don39t match the filter condition. Rows are hidden using the setrow() visible parameter. Excel::Writer::XLSX cannot do this automatically since it isn39t part of the file format. See the autofilter. pl program in the examples directory of the distro for an example. The conditions for the filter are specified using simple expressions: The column parameter can either be a zero indexed column number or a string column name. The following operators are available: The operator synonyms are just syntactic sugar to make you more comfortable using the expressions. It is important to remember that the expressions will be interpreted by Excel and not by perl. An expression can comprise a single statement or two statements separated by the and and or operators. For example: Filtering of blank or non-blank data can be achieved by using a value of Blanks or NonBlanks in the expression: Excel also allows some simple string matching operations: You can also use to match any character or number and. to match any single character or number. No other regular expression quantifier is supported by Excel39s filters. Excel39s regular expression characters can be escaped using The placeholder variable x in the above examples can be replaced by any simple string. The actual placeholder name is ignored internally so the following are all equivalent: Also, note that a filter condition can only be applied to a column in a range specified by the autofilter() Worksheet method. See the autofilter. pl program in the examples directory of the distro for a more detailed example. Note Spreadsheet::WriteExcel supports Top 10 style filters. These aren39t currently supported by Excel::Writer::XLSX but may be added later. Prior to Excel 2007 it was only possible to have either 1 or 2 filter conditions such as the ones shown above in the filtercolumn method. Excel 2007 introduced a new list style filter where it is possible to specify 1 or more 39or39 style criteria. For example if your column contained data for the first six months the initial data would be displayed as all selected as shown on the left. Then if you selected 39March39, 39April39 and 39May39 they would be displayed as shown on the right. The filtercolumnlist() method can be used to represent these types of filters: The column parameter can either be a zero indexed column number or a string column name. One or more criteria can be selected: NOTE: It isn39t sufficient to just specify the filter condition. You must also hide any rows that don39t match the filter condition. Rows are hidden using the setrow() visible parameter. Excel::Writer::XLSX cannot do this automatically since it isn39t part of the file format. See the autofilter. pl program in the examples directory of the distro for an example. The convertdatetime() method is used internally by the writedatetime() method to convert date strings to a number that represents an Excel date and time. It is exposed as a public method for utility purposes. The datestring format is detailed in the writedatetime() method. The Worksheet setvbaname() method can be used to set the VBA codename for the worksheet (there is a similar method for the workbook VBA name). This is sometimes required when a vbaProject macro included via addvbaproject() refers to the worksheet. The default Excel VBA name of Sheet1. etc. is used if a user defined name isn39t specified. Page set-up methods affect the way that a worksheet looks when it is printed. They control features such as page headers and footers and margins. These methods are really just standard worksheet methods. They are documented here in a separate section for the sake of clarity. The following methods are available for page set-up: A common requirement when working with Excel::Writer::XLSX is to apply the same page set-up features to all of the worksheets in a workbook. To do this you can use the sheets() method of the workbook class to access the array of worksheets in a workbook: This method is used to set the orientation of a worksheet39s printed page to landscape: This method is used to set the orientation of a worksheet39s printed page to portrait. The default worksheet orientation is portrait, so you won39t generally need to call this method. This method is used to display the worksheet in 34Page ViewLayout34 mode. This method is used to set the paper format for the printed output of a worksheet. The following paper styles are available: Note, it is likely that not all of these paper types will be available to the end user since it will depend on the paper formats that the user39s printer supports. Therefore, it is best to stick to standard paper types. If you do not specify a paper type the worksheet will print using the printer39s default paper. Center the worksheet data horizontally between the margins on the printed page: Center the worksheet data vertically between the margins on the printed page: There are several methods available for setting the worksheet margins on the printed page: All of these methods take a distance in inches as a parameter. Note: 1 inch 25.4mm. -) The default left and right margin is 0.7 inch. The default top and bottom margin is 0.75 inch. Note, these defaults are different from the defaults used in the binary file format by Spreadsheet::WriteExcel. Headers and footers are generated using a string which is a combination of plain text and control characters. The margin parameter is optional. The available control character are: Text in headers and footers can be justified (aligned) to the left, center and right by prefixing the text with the control characters 38L. 38C and 38R . For example (with ASCII art representation of the results): For simple text, if you do not specify any justification the text will be centred. However, you must prefix the text with 38C if you specify a font name or any other formatting: You can have text in each of the justification regions: The information control characters act as variables that Excel will update as the workbook or worksheet changes. Times and dates are in the users default format: Images can be inserted using the options shown below. Each image must have a placeholder in header string using the 38Picture or 38G control characters: You can specify the font size of a section of the text by prefixing it with the control character 38n where n is the font size: You can specify the font of a section of the text by prefixing it with the control sequence 3834font, style34 where fontname is a font name such as 34Courier New34 or 34Times New Roman34 and style is one of the standard Windows font descriptions: 34Regular34, 34Italic34, 34Bold34 or 34Bold Italic34: It is possible to combine all of these features together to create sophisticated headers and footers. As an aid to setting up complicated headers and footers you can record a page set-up as a macro in Excel and look at the format strings that VBA produces. Remember however that VBA uses two double quotes 3434 to indicate a single double quote. For the last example above the equivalent VBA code looks like this: To include a single literal ampersand 38 in a header or footer you should use a double ampersand 3838 : As stated above the margin parameter is optional. As with the other margins the value should be in inches. The default header and footer margin is 0.3 inch. Note, the default margin is different from the default used in the binary file format by Spreadsheet::WriteExcel. The header and footer margin size can be set as follows: The header and footer margins are independent of the top and bottom margins. The available options are: imageleft The path to the image. Requires a 38G or 38Picture placeholder. imagecenter Same as above. imageright Same as above. scalewithdoc Scale header with document. Defaults to true. alignwithmargins Align header to margins. Defaults to true. The image options must have an accompanying 38Picture or 38G control character in the header string: Note, the header or footer string must be less than 255 characters. Strings longer than this will not be written and a warning will be generated. The setheader() method can also handle Unicode strings in UTF-8 format. See, also the headers. pl program in the examples directory of the distribution. The syntax of the setfooter() method is the same as setheader(). see above. Set the number of rows to repeat at the top of each printed page. For large Excel documents it is often desirable to have the first row or rows of the worksheet print out at the top of each page. This can be achieved by using the repeatrows() method. The parameters firstrow and lastrow are zero based. The lastrow parameter is optional if you only wish to specify one row: Set the columns to repeat at the left hand side of each printed page. For large Excel documents it is often desirable to have the first column or columns of the worksheet print out at the left hand side of each page. This can be achieved by using the repeatcolumns() method. The parameters firstcolumn and lastcolumn are zero based. The lastcolumn parameter is optional if you only wish to specify one column. You can also specify the columns using A1 column notation, see the note about 34Cell notation34 . This method is used to hide the gridlines on the screen and printed page. Gridlines are the lines that divide the cells on a worksheet. Screen and printed gridlines are turned on by default in an Excel worksheet. If you have defined your own cell borders you may wish to hide the default gridlines. The following values of option are valid: If you don39t supply an argument or use undef the default option is 1, i. e. only the printed gridlines are hidden. Set the option to print the row and column headers on the printed page. An Excel worksheet looks something like the following The headers are the letters and numbers at the top and the left of the worksheet. Since these headers serve mainly as a indication of position on the worksheet they generally do not appear on the printed page. If you wish to have them printed you can use the printrowcolheaders() method : Do not confuse these headers with page headers as described in the setheader() section above. This method is used to specify the area of the worksheet that will be printed. All four parameters must be specified. You can also use A1 notation, see the note about 34Cell notation34 . The printacross method is used to change the default print direction. This is referred to by Excel as the sheet 34page order34. The default page order is shown below for a worksheet that extends over 4 pages. The order is called 34down then across34: However, by using the printacross method the print order will be changed to 34across then down34: The fittopages() method is used to fit the printed area to a specific number of pages both vertically and horizontally. If the printed area exceeds the specified number of pages it will be scaled down to fit. This guarantees that the printed area will always appear on the specified number of pages even if the page size or margins change. The print area can be defined using the printarea() method as described above. A common requirement is to fit the printed output to n pages wide but have the height be as long as necessary. To achieve this set the height to zero: Note that although it is valid to use both fittopages() and setprintscale() on the same worksheet only one of these options can be active at a time. The last method call made will set the active option. Note that fittopages() will override any manual page breaks that are defined in the worksheet. Note: When using fittopages() it may also be required to set the printer paper size using setpaper() or else Excel will default to 34US Letter34. The setstartpage() method is used to set the number of the starting page when the worksheet is printed out. The default value is 1. Set the scale factor of the printed page. Scale factors in the range 10 60 scale 60 400 are valid: The default scale factor is 100. Note, setprintscale() does not affect the scale of the visible page in Excel. For that you should use setzoom() . Note also that although it is valid to use both fittopages() and setprintscale() on the same worksheet only one of these options can be active at a time. The last method call made will set the active option. Set the option to print the worksheet in black and white: Add horizontal page breaks to a worksheet. A page break causes all the data that follows it to be printed on the next page. Horizontal page breaks act between rows. To create a page break between rows 20 and 21 you must specify the break at row 21. However in zero index notation this is actually row 20. So you can pretend for a small while that you are using 1 index notation: The sethpagebreaks() method will accept a list of page breaks and you can call it more than once: Note: If you specify the 34fit to page34 option via the fittopages() method it will override all manual page breaks. There is a silent limitation of about 1000 horizontal page breaks per worksheet in line with an Excel internal limitation. Add vertical page breaks to a worksheet. A page break causes all the data that follows it to be printed on the next page. Vertical page breaks act between columns. To create a page break between columns 20 and 21 you must specify the break at column 21. However in zero index notation this is actually column 20. So you can pretend for a small while that you are using 1 index notation: The setvpagebreaks() method will accept a list of page breaks and you can call it more than once: Note: If you specify the 34fit to page34 option via the fittopages() method it will override all manual page breaks. This section describes the methods and properties that are available for formatting cells in Excel. The properties of a cell that can be formatted include: fonts, colours, patterns, borders, alignment and number formatting. Cell formatting is defined through a Format object. Format objects are created by calling the workbook addformat() method as follows: The format object holds all the formatting properties that can be applied to a cell, a row or a column. The process of setting these properties is discussed in the next section. Once a Format object has been constructed and its properties have been set it can be passed as an argument to the worksheet write methods as follows: Formats can also be passed to the worksheet setrow() and setcolumn() methods to define the default property for a row or column. The following table shows the Excel format categories, the formatting properties that can be applied and the equivalent object method: There are two ways of setting Format properties: by using the object method interface or by setting the property directly. For example, a typical use of the method interface would be as follows: By comparison the properties can be set directly by passing a hash of properties to the Format constructor: or after the Format has been constructed by means of the setformatproperties() method as follows: You can also store the properties in one or more named hashes and pass them to the required method: The provision of two ways of setting properties might lead you to wonder which is the best way. The method mechanism may be better if you prefer setting properties via method calls (which the author did when the code was first written) otherwise passing properties to the constructor has proved to be a little more flexible and self documenting in practice. An additional advantage of working with property hashes is that it allows you to share formatting between workbook objects as shown in the example above. The PerlTk style of adding properties is also supported: The default format is Calibri 11 with all other properties off. Each unique format in Excel::Writer::XLSX must have a corresponding Format object. It isn39t possible to use a Format with a write() method and then redefine the Format for use at a later stage. This is because a Format is applied to a cell not in its current state but in its final state. Consider the following example: Cell A1 is assigned the Format format which is initially set to the colour red. However, the colour is subsequently set to green. When Excel displays Cell A1 it will display the final state of the Format which in this case will be the colour green. In general a method call without an argument will turn a property on, for example: The Format object methods are described in more detail in the following sections. In addition, there is a Perl program called formats. pl in the examples directory of the WriteExcel distribution. This program creates an Excel workbook called formats. xlsx which contains examples of almost all the format types. The following Format methods are available: The above methods can also be applied directly as properties. For example format-62setbold() is equivalent to workbook-62addformat(bold 62 1) . The properties of an existing Format object can be also be set by means of setformatproperties() : However, this method is here mainly for legacy reasons. It is preferable to set the properties in the format constructor: Specify the font used: Excel can only display fonts that are installed on the system that it is running on. Therefore it is best to use the fonts that come as standard such as 39Calibri39, 39Times New Roman39 and 39Courier New39. See also the Fonts worksheet created by formats. pl Set the font size. Excel adjusts the height of a row to accommodate the largest font size in the row. You can also explicitly specify the height of a row using the setrow() worksheet method. Set the font colour. The setcolor() method is used as follows: Note: The setcolor() method is used to set the colour of the font in a cell. To set the colour of a cell use the setbgcolor() and setpattern() methods. For additional examples see the 39Named colors39 and 39Standard colors39 worksheets created by formats. pl in the examples directory. Set the bold property of the font: Set the italic property of the font: This method is used to define the numerical format of a number in Excel. It controls whether a number is displayed as an integer, a floating point number, a date, a currency value or some other user defined format. The numerical format of a cell can be specified by using a format string or an index to one of Excel39s built-in formats: Using format strings you can define very sophisticated formatting of numbers. The number system used for dates is described in 34DATES AND TIME IN EXCEL34 . The colour format should have one of the following values: Alternatively you can specify the colour based on a colour index as follows: Color n. where n is a standard Excel colour index - 7. See the 39Standard colors39 worksheet created by formats. pl. For more information refer to the documentation on formatting in the docs directory of the Excel::Writer::XLSX distro, the Excel on-line help or office. microsoften-gbassistanceHP051995001033.aspx . You should ensure that the format string is valid in Excel prior to using it in WriteExcel. Excel39s built-in formats are shown in the following table: For examples of these formatting codes see the 39Numerical formats39 worksheet created by formats. pl. See also the numberformats1.html and the numberformats2.html documents in the docs directory of the distro. Note 1. Numeric formats 23 to 36 are not documented by Microsoft and may differ in international versions. Note 2. The dollar sign appears as the defined local currency symbol. This property can be used to prevent modification of a cells contents. Following Excel39s convention, cell locking is turned on by default. However, it only has an effect if the worksheet has been protected, see the worksheet protect() method. Note: This offers weak protection even with a password, see the note in relation to the protect() method. This property is used to hide a formula while still displaying its result. This is generally used to hide complex calculations from end users who are only interested in the result. It only has an effect if the worksheet has been protected, see the worksheet protect() method. Note: This offers weak protection even with a password, see the note in relation to the protect() method. This method is used to set the horizontal and vertical text alignment within a cell. Vertical and horizontal alignments can be combined. The method is used as follows: Text can be aligned across two or more adjacent cells using the centeracross property. However, for genuine merged cells it is better to use the mergerange() worksheet method. The vjustify (vertical justify) option can be used to provide automatic text wrapping in a cell. The height of the cell will be adjusted to accommodate the wrapped text. To specify where the text wraps use the settextwrap() method. For further examples see the 39Alignment39 worksheet created by formats. pl. Text can be aligned across two or more adjacent cells using the setcenteracross() method. This is an alias for the setalign(39centeracross39) method call. Only one cell should contain the text, the other cells should be blank: See also the merge1.pl to merge6.pl programs in the examples directory and the mergerange() method. Here is an example using the text wrap property, the escape character n is used to indicate the end of line: Excel will adjust the height of the row to accommodate the wrapped text. A similar effect can be obtained without newlines using the setalign(39vjustify39) method. See the textwrap. pl program in the examples directory. Set the rotation of the text in a cell. The rotation can be any angle in the range -90 to 90 degrees. The angle 270 is also supported. This indicates text where the letters run from top to bottom. This method can be used to indent text. The argument, which should be an integer, is taken as the level of indentation: Indentation is a horizontal alignment property. It will override any other horizontal properties but it can be used in conjunction with vertical properties. This method can be used to shrink text so that it fits in a cell. Only applies to Far Eastern versions of Excel. Set the background pattern of a cell. Examples of the available patterns are shown in the 39Patterns39 worksheet created by formats. pl. However, it is unlikely that you will ever need anything other than Pattern 1 which is a solid fill of the background color. The setbgcolor() method can be used to set the background colour of a pattern. Patterns are defined via the setpattern() method. If a pattern hasn39t been defined then a solid fill pattern is used as the default. Here is an example of how to set up a solid fill in a cell: For further examples see the 39Patterns39 worksheet created by formats. pl. The setfgcolor() method can be used to set the foreground colour of a pattern. For further examples see the 39Patterns39 worksheet created by formats. pl. A cell border is comprised of a border on the bottom, top, left and right. These can be set to the same value using setborder() or individually using the relevant method calls shown above. The following shows the border styles sorted by Excel::Writer::XLSX index number: The following shows the borders sorted by style: The following shows the borders in the order shown in the Excel Dialog. Examples of the available border styles are shown in the 39Borders39 worksheet created by formats. pl. Set the colour of the cell borders. A cell border is comprised of a border on the bottom, top, left and right. These can be set to the same colour using setbordercolor() or individually using the relevant method calls shown above. Examples of the border styles and colours are shown in the 39Borders39 worksheet created by formats. pl. Set the diagonal border type for the cell. Three types of diagonal borders are available in Excel: Set the diagonal border style. Same as the parameter to setborder() above. Set the colour of the diagonal cell border: This method is used to copy all of the properties from one Format object to another: The copy() method is only useful if you are using the method interface to Format properties. It generally isn39t required if you are setting Format properties directly using hashes. Note: this is not a copy constructor, both objects must exist prior to copying. The following is a brief introduction to handling Unicode in Excel::Writer::XLSX . For a more general introduction to Unicode handling in Perl see perlunitut and perluniintro . Excel::Writer::XLSX writer differs from Spreadsheet::WriteExcel in that it only handles Unicode data in UTF-8 format and doesn39t try to handle legacy UTF-16 Excel formats. If the data is in UTF-8 format then Excel::Writer::XLSX will handle it automatically. If you are dealing with non-ASCII characters that aren39t in UTF-8 then perl provides useful tools in the guise of the Encode module to help you to convert to the required format. For example: Alternatively you can read data from an encoded file and convert it to UTF-8 as you read it in: If the program contains UTF-8 text then you will also need to add use utf8 to the includes: See also the unicode. pl programs in the examples directory of the distro. Throughout Excel::Writer::XLSX colours can be specified using a Html style RRGGBB value. For example with a Format object: For backward compatibility a limited number of color names are supported: The color names supported are: See also colors. pl in the examples directory. There are two important things to understand about dates and times in Excel: These two points are explained in more detail below along with some suggestions on how to convert times and dates to the required format. If you write a date string with write() then all you will get is a string: Dates and times in Excel are represented by real numbers, for example 34Jan 1 2001 12:30 AM34 is represented by the number 36892.521. The integer part of the number stores the number of days since the epoch and the fractional part stores the percentage of the day. A date or time in Excel is just like any other number. To have the number display as a date you must apply an Excel number format to it. Oto kilka przykładów. Excel::Writer::XLSX doesn39t automatically convert input date strings into Excel39s formatted date numbers due to the large number of possible date formats and also due to the possibility of misinterpretation. For example, does 020304 mean March 2 2004, February 3 2004 or even March 4 2002. Therefore, in order to handle dates you will have to convert them to numbers and apply an Excel format. Some methods for converting dates are listed in the next section. The most direct way is to convert your dates to the ISO8601 yyyy-mm-ddThh:mm:ss. sss date format and use the writedatetime() worksheet method: See the writedatetime() section of the documentation for more details. A general methodology for handling date strings with writedatetime() is: Here is an example: For a slightly more advanced solution you can modify the write() method to handle date formats of your choice via the addwritehandler() method. See the addwritehandler() section of the docs and the writehandler3.pl and writehandler4.pl programs in the examples directory of the distro. The writedatetime() method above is just one way of handling dates and times. You can also use the convertdatetime() worksheet method to convert from an ISO8601 style date string to an Excel date and time number. The Excel::Writer::XLSX::Utility module which is included in the distro has datetime handling functions: Note: some of these functions require additional CPAN modules. Excel allows you to group rows or columns so that they can be hidden or displayed with a single mouse click. This feature is referred to as outlines. Outlines can reduce complex data down to a few salient sub-totals or summaries. This feature is best viewed in Excel but the following is an ASCII representation of what a worksheet with three outlines might look like. Rows 3-4 and rows 7-8 are grouped at level 2. Rows 2-9 are grouped at level 1. The lines at the left hand side are called outline level bars. Clicking the minus sign on each of the level 2 outlines will collapse and hide the data as shown in the next figure. The minus sign changes to a plus sign to indicate that the data in the outline is hidden. Clicking on the minus sign on the level 1 outline will collapse the remaining rows as follows: Grouping in Excel::Writer::XLSX is achieved by setting the outline level via the setrow() and setcolumn() worksheet methods: The following example sets an outline level of 1 for rows 1 and 2 (zero-indexed) and columns B to G. The parameters height and XF are assigned default values since they are undefined: Excel allows up to 7 outline levels. Therefore the level parameter should be in the range 0 60 level 60 7 . Rows and columns can be collapsed by setting the hidden flag for the hidden rowscolumns and setting the collapsed flag for the rowcolumn that has the collapsed symbol: Note: Setting the collapsed flag is particularly important for compatibility with OpenOffice. org and Gnumeric. For a more complete example see the outline. pl and outlinecollapsed. pl programs in the examples directory of the distro. Some additional outline properties can be set via the outlinesettings() worksheet method, see above. Data validation is a feature of Excel which allows you to restrict the data that a users enters in a cell and to display help and warning messages. It also allows you to restrict input to values in a drop down list. A typical use case might be to restrict data in a cell to integer values in a certain range, to provide a help message to indicate the required value and to issue a warning if the input data doesn39t meet the stated criteria. In Excel::Writer::XLSX we could do that as follows: For more information on data validation see the following Microsoft support article 34Description and examples of data validation in Excel34: support. microsoftkb211485 . The following sections describe how to use the datavalidation() method and its various options. datavalidation( row, col, ) The datavalidation() method is used to construct an Excel data validation. It can be applied to a single cell or a range of cells. You can pass 3 parameters such as (row, col, ) or 5 parameters such as (firstrow, firstcol, lastrow, lastcol, ). You can also use A1 style notation. For example: See also the note about 34Cell notation34 for more information. The last parameter in datavalidation() must be a hash ref containing the parameters that describe the type and style of the data validation. The allowable parameters are: These parameters are explained in the following sections. Most of the parameters are optional, however, you will generally require the three main options validate. criteria and value . The datavalidation method returns: This parameter is passed in a hash ref to datavalidation() . The validate parameter is used to set the type of data that you wish to validate. It is always required and it has no default value. Allowable values are: any is used to specify that the type of data is unrestricted. This is useful to display an input message without restricting the data that can be entered. integer restricts the cell to integer values. Excel refers to this as 39whole number39. decimal restricts the cell to decimal values. list restricts the cell to a set of user specified values. These can be passed in an array ref or as a cell range (named ranges aren39t currently supported): Excel requires that range references are only to cells on the same worksheet. date restricts the cell to date values. Dates in Excel are expressed as integer values but you can also pass an ISO8601 style string as used in writedatetime(). See also 34DATES AND TIME IN EXCEL34 for more information about working with Excel39s dates. time restricts the cell to time values. Times in Excel are expressed as decimal values but you can also pass an ISO8601 style string as used in writedatetime(). See also 34DATES AND TIME IN EXCEL34 for more information about working with Excel39s times. length restricts the cell data based on an integer string length. Excel refers to this as 39Text length39. custom restricts the cell based on an external Excel formula that returns a TRUEFALSE value. This parameter is passed in a hash ref to datavalidation() . The criteria parameter is used to set the criteria by which the data in the cell is validated. It is almost always required except for the list and custom validate options. It has no default value. Allowable values are: You can either use Excel39s textual description strings, in the first column above, or the more common symbolic alternatives. The following are equivalent: The list and custom validate options don39t require a criteria. If you specify one it will be ignored. This parameter is passed in a hash ref to datavalidation() . The value parameter is used to set the limiting value to which the criteria is applied. It is always required and it has no default value. You can also use the synonyms minimum or source to make the validation a little clearer and closer to Excel39s description of the parameter: This parameter is passed in a hash ref to datavalidation() . The maximum parameter is used to set the upper limiting value when the criteria is either 39between39 or 39not between39 : This parameter is passed in a hash ref to datavalidation() . The ignoreblank parameter is used to toggle on and off the 39Ignore blank39 option in the Excel data validation dialog. When the option is on the data validation is not applied to blank data in the cell. It is on by default. This parameter is passed in a hash ref to datavalidation() . The dropdown parameter is used to toggle on and off the 39In-cell dropdown39 option in the Excel data validation dialog. When the option is on a dropdown list will be shown for list validations. It is on by default. This parameter is passed in a hash ref to datavalidation() . The inputtitle parameter is used to set the title of the input message that is displayed when a cell is entered. It has no default value and is only displayed if the input message is displayed. See the inputmessage parameter below. The maximum title length is 32 characters. This parameter is passed in a hash ref to datavalidation() . The inputmessage parameter is used to set the input message that is displayed when a cell is entered. It has no default value. The message can be split over several lines using newlines, 34n34 in double quoted strings. The maximum message length is 255 characters. This parameter is passed in a hash ref to datavalidation() . The showinput parameter is used to toggle on and off the 39Show input message when cell is selected39 option in the Excel data validation dialog. When the option is off an input message is not displayed even if it has been set using inputmessage. It is on by default. This parameter is passed in a hash ref to datavalidation() . The errortitle parameter is used to set the title of the error message that is displayed when the data validation criteria is not met. The default error title is 39Microsoft Excel39. The maximum title length is 32 characters. This parameter is passed in a hash ref to datavalidation() . The errormessage parameter is used to set the error message that is displayed when a cell is entered. The default error message is 34The value you entered is not valid. nA user has restricted values that can be entered into the cell.34. The message can be split over several lines using newlines, 34n34 in double quoted strings. The maximum message length is 255 characters. This parameter is passed in a hash ref to datavalidation() . The errortype parameter is used to specify the type of error dialog that is displayed. There are 3 options: The default is 39stop39 . This parameter is passed in a hash ref to datavalidation() . The showerror parameter is used to toggle on and off the 39Show error alert after invalid data is entered39 option in the Excel data validation dialog. When the option is off an error message is not displayed even if it has been set using errormessage. It is on by default. Example 1. Limiting input to an integer greater than a fixed value. Example 2. Limiting input to an integer greater than a fixed value where the value is referenced from a cell. Example 3. Limiting input to a decimal in a fixed range. Example 4. Limiting input to a value in a dropdown list. Example 5. Limiting input to a value in a dropdown list where the list is specified as a cell range. Example 6. Limiting input to a date in a fixed range. Example 7. Displaying a message when the cell is selected. See also the datavalidate. pl program in the examples directory of the distro. Conditional formatting is a feature of Excel which allows you to apply a format to a cell or a range of cells based on a certain criteria. For example the following criteria is used to highlight cells 62 50 in red in the conditionalformat. pl example from the distro: conditionalformatting( row, col, ) The conditionalformatting() method is used to apply formatting based on user defined criteria to an Excel::Writer::XLSX file. It can be applied to a single cell or a range of cells. You can pass 3 parameters such as (row, col, ) or 5 parameters such as (firstrow, firstcol, lastrow, lastcol, ). You can also use A1 style notation. For example: See also the note about 34Cell notation34 for more information. Using A1 style notation is also possible to specify non-contiguous ranges, separated by a comma. For example: The last parameter in conditionalformatting() must be a hash ref containing the parameters that describe the type and style of the data validation. The main parameters are: Other, less commonly used parameters are: Additional parameters which are used for specific conditional format types are shown in the relevant sections below. This parameter is passed in a hash ref to conditionalformatting() . The type parameter is used to set the type of conditional formatting that you wish to apply. It is always required and it has no default value. Allowable type values and their associated parameters are: All conditional formatting types have a format parameter, see below. Other types and parameters such as icon sets will be added in time. This is the most common conditional formatting type. It is used when a format is applied to a cell based on a simple criterion. For example: Or, using the between criteria: The criteria parameter is used to set the criteria by which the cell data will be evaluated. It has no default value. The most common criteria as applied to are: You can either use Excel39s textual description strings, in the first column above, or the more common symbolic alternatives. Additional criteria which are specific to other conditional format types are shown in the relevant sections below. The value is generally used along with the criteria parameter to set the rule by which the cell data will be evaluated. The value property can also be an cell reference. The format parameter is used to specify the format that will be applied to the cell when the conditional formatting criterion is met. The format is created using the addformat() method in the same way as cell formats: The conditional format follows the same rules as in Excel: it is superimposed over the existing cell format and not all font and border properties can be modified. Font properties that can39t be modified are font name, font size, superscript and subscript. The border property that cannot be modified is diagonal borders. Excel specifies some default formats to be used with conditional formatting. You can replicate them using the following Excel::Writer::XLSX formats: The minimum parameter is used to set the lower limiting value when the criteria is either 39between39 or 39not between39 : The maximum parameter is used to set the upper limiting value when the criteria is either 39between39 or 39not between39. See the previous example. The date type is the same as the cell type and uses the same criteria and values. However it allows the value. minimum and maximum properties to be specified in the ISO8601 yyyy-mm-ddThh:mm:ss. sss date format which is detailed in the writedatetime() method. The timeperiod type is used to specify Excel39s 34Dates Occurring34 style conditional format. The period is set in the criteria and can have one of the following values: The text type is used to specify Excel39s 34Specific Text34 style conditional format. It is used to do simple string matching using the criteria and value parameters: The criteria can have one of the following values: The value parameter should be a string or single character. The average type is used to specify Excel39s 34Average34 style conditional format. The type of average for the conditional format range is specified by the criteria : The duplicate type is used to highlight duplicate cells in a range: The unique type is used to highlight unique cells in a range: The top type is used to specify the top n values by number or percentage in a range: The criteria can be used to indicate that a percentage condition is required: The bottom type is used to specify the bottom n values by number or percentage in a range. It takes the same parameters as top. see above. The blanks type is used to highlight blank cells in a range: The noblanks type is used to highlight non blank cells in a range: The errors type is used to highlight error cells in a range: The noerrors type is used to highlight non error cells in a range: The 2colorscale type is used to specify Excel39s 342 Color Scale34 style conditional format. This conditional type can be modified with mintype. maxtype. minvalue. maxvalue. mincolor and maxcolor. see below. The 3colorscale type is used to specify Excel39s 343 Color Scale34 style conditional format. This conditional type can be modified with mintype. midtype. maxtype. minvalue. midvalue. maxvalue. mincolor. midcolor and maxcolor. see below. The databar type is used to specify Excel39s 34Data Bar34 style conditional format. This conditional type can be modified with mintype. maxtype. minvalue. maxvalue and barcolor. see below. The formula type is used to specify a conditional format based on a user defined formula: The formula is specified in the criteria . The mintype and maxtype properties are available when the conditional formatting type is 2colorscale. 3colorscale or databar. The midtype is available for 3colorscale. The properties are used as follows: The available minmidmax types are: The minvalue and maxvalue properties are available when the conditional formatting type is 2colorscale. 3colorscale or databar. The midvalue is available for 3colorscale. The properties are used as follows: The mincolor and maxcolor properties are available when the conditional formatting type is 2colorscale. 3colorscale or databar. The midcolor is available for 3colorscale. The properties are used as follows: The color can be specifies as an Excel::Writer::XLSX color index or, more usefully, as a HTML style RGB hex number, as shown above. The stopiftrue parameter, if set to a true value, will enable the 34stop if true34 feature on the conditional formatting rule, so that subsequent rules are not examined for any cell on which the conditions for this rule are met. Example 1. Highlight cells greater than an integer value. Example 2. Highlight cells greater than a value in a reference cell. Example 3. Highlight cells greater than a certain date: Example 4. Highlight cells with a date in the last seven days: Example 5. Highlight cells with strings starting with the letter b : Example 6. Highlight cells that are 1 std deviation above the average for the range: Example 7. Highlight duplicate cells in a range: Example 8. Highlight unique cells in a range. Example 9. Highlight the top 10 cells. Example 10. Highlight blank cells. See also the conditionalformat. pl example program in EXAMPLES . Sparklines are a feature of Excel 2017 which allows you to add small charts to worksheet cells. These are useful for showing visual trends in data in a compact format. In Excel::Writer::XLSX Sparklines can be added to cells using the addsparkline() worksheet method: Note: Sparklines are a feature of Excel 2017 only. You can write them to an XLSX file that can be read by Excel 2007 but they won39t be displayed. addsparkline( ) The addsparkline() worksheet method is used to add sparklines to a cell or a range of cells. The parameters to addsparkline() must be passed in a hash ref. The main sparkline parameters are: Other, less commonly used parameters are: These parameters are explained in the sections below: This is the cell where the sparkline will be displayed: The location should be a single cell. (For multiple cells see 34Grouped Sparklines34 below). To specify the location in row-column notation use the xlrowcoltocell() function from the Excel::Writer::XLSX::Utility module. This specifies the cell data range that the sparkline will plot: The range should be a 2D array. (For 3D arrays of cells see 34Grouped Sparklines34 below). If range is not on the same worksheet you can specify its location using the usual Excel notation: If the worksheet contains spaces or special characters you should quote the worksheet name in the same way that Excel does: To specify the location in row-column notation use the xlrange() or xlrangeformula() functions from the Excel::Writer::XLSX::Utility module. Specifies the type of sparkline. There are 3 available sparkline types: Excel provides 36 built-in Sparkline styles in 6 groups of 6. The style parameter can be used to replicate these and should be a corresponding number from 1. 36. The style number starts in the top left of the style grid and runs left to right. The default style is 1. It is possible to override colour elements of the sparklines using the color parameters below. Turn on the markers for line style sparklines. Markers aren39t shown in Excel for column and winloss sparklines. Highlight negative values in a sparkline range. This is usually required with winloss sparklines. Display a horizontal axis in the sparkline: Plot the data from right-to-left instead of the default left-to-right: Adjust the default line weight (thickness) for line style sparklines. The weight value should be one of the following values allowed by Excel: Highlight points in a sparkline range. Specify the maximum and minimum vertical axis values: As a special case you can set the maximum and minimum to be for a group of sparklines rather than one: Define how empty cells are handled in a sparkline. The available options are: Plot data in hidden rows and columns: Note, this option is off by default. Specify an alternative date axis for the sparkline. This is useful if the data being plotted isn39t at fixed width intervals: The number of cells in the date range should correspond to the number of cells in the data range. It is possible to override the colour of a sparkline style using the following parameters: The color should be specified as a HTML style rrggbb hex value: The addsparkline() worksheet method can be used multiple times to write as many sparklines as are required in a worksheet. However, it is sometimes necessary to group contiguous sparklines so that changes that are applied to one are applied to all. In Excel this is achieved by selecting a 3D range of cells for the data range and a 2D range of cells for the location . In Excel::Writer::XLSX, you can simulate this by passing an array refs of values to location and range : See the sparklines1.pl and sparklines2.pl example programs in the examples directory of the distro. Tables in Excel are a way of grouping a range of cells into a single entity that has common formatting or that can be referenced from formulas. Tables can have column headers, autofilters, total rows, column formulas and default formatting. Note, tables don39t work in Excel::Writer::XLSX when setoptimization() mode in on. addtable( row1, col1, row2, col2, ) Tables are added to a worksheet using the addtable() method: The data range can be specified in 39A139 or 39rowcol39 notation (see also the note about 34Cell notation34 for more information): The last parameter in addtable() should be a hash ref containing the parameters that describe the table options and data. The available parameters are: The table parameters are detailed below. There are no required parameters and the hash ref isn39t required if no options are specified. The data parameter can be used to specify the data in the cells of the table. Table data can also be written separately, as an array or individual cells. Writing the cell data separately is occasionally required when you need to control the write() method used to populate the cells or if you wish to tweak the cell formatting. The data structure should be an array ref of array refs holding row data as shown above. The headerrow parameter can be used to turn on or off the header row in the table. It is on by default. The header row will contain default captions such as Column 1. Column 2. etc. These captions can be overridden using the columns parameter below. The autofilter parameter can be used to turn on or off the autofilter in the header row. It is on by default. The autofilter is only shown if the headerrow is on. Filters within the table are not supported. The bandedrows parameter can be used to used to create rows of alternating colour in the table. It is on by default. The bandedcolumns parameter can be used to used to create columns of alternating colour in the table. It is off by default. The firstcolumn parameter can be used to highlight the first column of the table. The type of highlighting will depend on the style of the table. It may be bold text or a different colour. It is off by default. The lastcolumn parameter can be used to highlight the last column of the table. The type of highlighting will depend on the style of the table. It may be bold text or a different colour. It is off by default. The style parameter can be used to set the style of the table. Standard Excel table format names should be used (with matching capitalisation): The default table style is 39Table Style Medium 939. By default tables are named Table1. Table2. etc. The name parameter can be used to set the name of the table: If you override the table name you must ensure that it doesn39t clash with an existing table name and that it follows Excel39s requirements for table names office. microsoften-001excel-helpdefine-and-use-names-in-formulas-HA010147120.aspxBMsyntaxrulesfornames . If you need to know the name of the table, for example to use it in a formula, you can get it as follows: The totalrow parameter can be used to turn on the total row in the last row of a table. It is distinguished from the other rows by a different formatting and also with dropdown SUBTOTAL functions. The default total row doesn39t have any captions or functions. These must by specified via the columns parameter below. The columns parameter can be used to set properties for columns within the table. The sub-properties that can be set are: The column data must be specified as an array ref of hash refs. For example to override the default 39Column n39 style table headers: If you don39t wish to specify properties for a specific column you pass an empty hash ref and the defaults will be applied: Column formulas can by applied using the formula column property: The Excel 2007 This Row and Excel 2017 structural references are supported within the formula. As stated above the totalrow table parameter turns on the 34Total34 row in the table but it doesn39t populate it with any defaults. Total captions and functions must be specified via the columns property and the totalstring. totalfunction and totalvalue sub properties: The supported totals row SUBTOTAL functions are: User defined functions or formulas aren39t supported. It is also possible to set a calculated value for the totalfunction using the totalvalue sub property. This is only necessary when creating workbooks for applications that cannot calculate the value of formulas automatically. This is similar to setting the value optional property in writeformula() : Formatting can also be applied to columns, to the column data using format and to the header using headerformat : Standard Excel::Writer::XLSX format objects can be used. However, they should be limited to numerical formats for the columns and simple formatting like text wrap for the headers. Overriding other table formatting may produce inconsistent results. The following is a brief introduction to formulas and functions in Excel and Excel::Writer::XLSX. A formula is a string that begins with an equals sign: The formula can contain numbers, strings, boolean values, cell references, cell ranges and functions. Named ranges are not supported. Formulas should be written as they appear in Excel, that is cells and functions must be in uppercase. Cells in Excel are referenced using the A1 notation system where the column is designated by a letter and the row by a number. Columns range from A to XFD i. e. 0 to 16384, rows range from 1 to 1048576. The Excel::Writer::XLSX::Utility module that is included in the distro contains helper functions for dealing with A1 notation, for example: The Excel notation in cell references is also supported. This allows you to specify whether a row or column is relative or absolute. This only has an effect if the cell is copied. The following examples show relative and absolute values. Formulas can also refer to cells in other worksheets of the current workbook. For example: The sheet reference and the cell reference are separated by. the exclamation mark symbol. If worksheet names contain spaces, commas or parentheses then Excel requires that the name is enclosed in single quotes as shown in the last two examples above. In order to avoid using a lot of escape characters you can use the quote operator q to protect the quotes. See perlop in the main Perl documentation. Only valid sheet names that have been added using the addworksheet() method can be used in formulas. You cannot reference external workbooks. The following table lists the operators that are available in Excel39s formulas. The majority of the operators are the same as Perl39s, differences are indicated: The range and comma operators can have different symbols in non-English versions of Excel, see below. For a general introduction to Excel39s formulas and an explanation of the syntax of the function refer to the Excel help files or the following: office. microsoften-usassistanceCH062528031033.aspx . In most cases a formula in Excel can be used directly in the writeformula method. However, there are a few potential issues and differences that the user should be aware of. These are explained in the following sections. Excel stores formulas in the format of the US English version, regardless of the language or locale of the end-user39s version of Excel. Therefore all formula function names written using Excel::Writer::XLSX must be in English: Also, formulas must be written with the US style separatorrange operator which is a comma (not semi-colon). Therefore a formula with multiple values should be written as follows: If you have a non-English version of Excel you can use the following multi-lingual Formula Translator (en. excel-translator. delanguage ) to help you convert the formula. It can also replace semi-colons with commas. Excel 2017 and later added functions which weren39t defined in the original file specification. These functions are referred to by Microsoft as future functions. Examples of these functions are ACOT. CHISQ. DIST. RT. CONFIDENCE. NORM. STDEV. P. STDEV. S and WORKDAY. INTL . When written using writeformula() these functions need to be fully qualified with a xlfn. (or other) prefix as they are shown the list below. For example: They will appear without the prefix in Excel. The following list is taken from the MS XLSX extensions documentation on future functions: msdn. microsoften-uslibrarydd90748028voffice.1229.aspx : Worksheet tables can be added with Excel::Writer::XLSX using the addtable() method: By default tables are named Table1. Table2. etc. in the order that they are added. However it can also be set by the user using the name parameter: If you need to know the name of the table, for example to use it in a formula, you can get it as follows: When used in a formula a table name such as TableX should be referred to as TableX (like a Perl array): If there is an error in the syntax of a formula it is usually displayed in Excel as NAME. If you encounter an error like this you can debug it as follows: Finally if you have completed all the previous steps and still get a NAME error you can examine a valid Excel file to see what the correct syntax should be. To do this you should create a valid formula in Excel and save the file. You can then examine the XML in the unzipped file. The following shows how to do that using Linux unzip and libxml39s xmllint xmlsoft. orgxmllint. html to format the XML for clarity: Excel::Writer::XLSX doesn39t calculate the result of a formula and instead stores the value 0 as the formula result. It then sets a global flag in the XLSX file to say that all formulas and functions should be recalculated when the file is opened. This is the method recommended in the Excel documentation and in general it works fine with spreadsheet applications. However, applications that don39t have a facility to calculate formulas will only display the 0 results. Examples of such applications are Excel Viewer, PDF Converters, and some mobile device applications. If required, it is also possible to specify the calculated result of the formula using the optional last value parameter in writeformula : The value parameter can be a number, a string, a boolean sting ( 39TRUE39 or 39FALSE39 ) or one of the following Excel error codes: It is also possible to specify the calculated result of an array formula created with writearrayformula : However, using this parameter only writes a single value to the upper left cell in the result array. For a multi-cell array formula where the results are required, the other result values can be specified by using writenumber() to write to the appropriate cell: An Excel xlsm file is exactly the same as a xlsx file except that is includes an additional vbaProject. bin file which contains functions andor macros. Excel uses a different extension to differentiate between the two file formats since files containing macros are usually subject to additional security checks. The vbaProject. bin file is a binary OLE COM container. This was the format used in older xls versions of Excel prior to Excel 2007. Unlike all of the other components of an xlsxxlsm file the data isn39t stored in XML format. Instead the functions and macros as stored as pre-parsed binary format. As such it wouldn39t be feasible to define macros and create a vbaProject. bin file from scratch (at least not in the remaining lifespan and interest levels of the author). Instead a workaround is used to extract vbaProject. bin files from existing xlsm files and then add these to Excel::Writer::XLSX files. The extractvba utility is used to extract the vbaProject. bin binary from an Excel 2007 xlsm file. The utility is included in the Excel::Writer::XLSX bin directory and is also installed as a standalone executable file: Once the vbaProject. bin file has been extracted it can be added to the Excel::Writer::XLSX workbook using the addvbaproject() method: If the VBA file contains functions you can then refer to them in calculations using writeformula : Excel files that contain functions and macros should use an xlsm extension or else Excel will complain and possibly not open the file: It is also possible to assign a macro to a button that is inserted into a worksheet using the insertbutton() method: It may be necessary to specify a more explicit macro name prefixed by the workbook VBA name as follows: See the macros. pl from the examples directory for a working example. Note: Button is the only VBA Control supported by Excel::Writer::XLSX. Due to the large effort in implementation (1 man months) it is unlikely that any other form elements will be added in the future. VBA macros generally refer to workbook and worksheet objects. If the VBA codenames aren39t specified then Excel::Writer::XLSX will use the Excel defaults of ThisWorkbook and Sheet1. Sheet2 etc. If the macro uses other codenames you can set them using the workbook and worksheet setvbaname() methods as follows: You can find the names that are used in the VBA editor or by unzipping the xlsm file and grepping the files. The following shows how to do that using libxml39s xmllint xmlsoft. orgxmllint. html to format the XML for clarity: Note: This step is particularly important for macros created with non-English versions of Excel. This feature should be considered experimental and there is no guarantee that it will work in all cases. Some effort may be required and some knowledge of VBA will certainly help. If things don39t work out here are some things to try: Start with a simple macro file, ensure that it works and then add complexity. Try to extract the macros from an Excel 2007 file. The method should work with macros from later versions (it was also tested with Excel 2017 macros). However there may be features in the macro files of more recent version of Excel that aren39t backward compatible. Check the code names that macros use to refer to the workbook and worksheets (see the previous section above). In general VBA uses a code name of ThisWorkbook to refer to the current workbook and the sheet name (such as Sheet1 ) to refer to the worksheets. These are the defaults used by Excel::Writer::XLSX. If the macro uses other names then you can specify these using the workbook and worksheet setvbaname() methods: The following example shows some of the basic features of Excel::Writer::XLSX. The following is a general example which demonstrates some features of working with multiple worksheets. Example of how to add conditional formatting to an Excel::Writer::XLSX file. The example below highlights cells that have a value greater than or equal to 50 in red and cells below that value in green. The following is a simple example of using functions. The following example converts a tab separated file called tab. txt into an Excel file called tab. xlsx . NOTE: This is a simple conversion program for illustrative purposes only. For converting a CSV or Tab separated or any other type of delimited text file to Excel I recommend the more rigorous csv2xls program that is part of H. Merijn Brand39s Text::CSVXS module distro. See the examplescsv2xls link here: search. cpan. org The following is a description of the example files that are provided in the standard Excel::Writer::XLSX distribution. They demonstrate the different features and options of the module. See Excel::Writer::XLSX::Examples for more details. The following limits are imposed by Excel 2007: Per worksheet. Excel allows a greater number of non-unique hyperlinks if they are contiguous and can be grouped into a single range. This will be supported in a later version of Excel::Writer::XLSX if possible. The Excel::Writer::XLSX module is a drop-in replacement for Spreadsheet::WriteExcel . It supports all of the features of Spreadsheet::WriteExcel with some minor differences noted below. Spreadsheet::WriteExcel was written to optimise speed and reduce memory usage. However, these design goals meant that it wasn39t easy to implement features that many users requested such as writing formatting and data separately. As a result Excel::Writer::XLSX takes a different design approach and holds a lot more data in memory so that it is functionally more flexible. The effect of this is that Excel::Writer::XLSX is about 30 slower than Spreadsheet::WriteExcel and uses 5 times more memory. In addition the extended row and column ranges in Excel 2007 mean that it is possible to run out of memory creating large files. This was almost never an issue with Spreadsheet::WriteExcel. This memory usage can be reduced almost completely by using the Workbook setoptimization() method: This also gives an increase in performance to within 1-10 of Spreadsheet::WriteExcel, see below. The trade-off is that you won39t be able to take advantage of any new features that manipulate cell data after it is written. One such feature is Tables. The performance figures below show execution speed and memory usage for 60 columns x N rows for a 5050 mixture of strings and numbers. Percentage speeds are relative to Spreadsheet::WriteExcel. The module can be installed using the standard Perl procedure: A filename must be given in the constructor. The file cannot be opened for writing. The directory that you are writing to may be protected or the file may be in use by another program. On Windows this is usually caused by the file that you are trying to create clashing with a version that is already open and locked by Excel. This warning occurs when you create an XLSX file but give it an xls extension. Depending on your requirements, background and general sensibilities you may prefer one of the following methods of getting data into Excel: This module is the precursor to Excel::Writer::XLSX and uses the same interface. It produces files in the Excel Biff xls format that was used in Excel versions 97-2003. These files can still be read by Excel 2007 but have some limitations in relation to the number of rows and columns that the format supports. Win32::OLE module and office automationThis requires a Windows platform and an installed copy of Excel. This is the most powerful and complete method for interfacing with Excel. CSV, comma separated variables or textExcel will open and automatically convert files with a csv extension. To create CSV files refer to the Text::CSVXS module. DBI with DBD::ADO or DBD::ODBCExcel files contain an internal index table that allows them to act like a database file. Using one of the standard Perl database modules you can connect to an Excel file as a database. To read data from Excel files try: A module for reading formatted or unformatted data form XLSX files. A lightweight module for reading data from XLSX files. This module can read data from an Excel XLS file but it doesn39t support the XLSX format. Win32::OLE module and office automation (reading)DBI with DBD::ADO or DBD::ODBC. Memory usage is very high for large worksheets. If you run out of memory creating large worksheets use the setoptimization() method. See 34SPEED AND MEMORY USAGE34 for more information. Perl packaging programs can39t find chart modules. When using Excel::Writer::XLSX charts with Perl packagers such as PAR or Cava you should explicitly include the chart that you are trying to create in your use statements. This isn39t a bug as such but it might help someone from banging their head off a wall: If you wish to submit a bug report run the bugreport. pl program in the examples directory of the distro. The roadmap is as follows: New separated dataformatting API to allow cells to be formatted after data is added. More charting features. There is a Google group for discussing and asking questions about Excel::Writer::XLSX. This is a good place to search to see if your question has been asked before: groups. googlegroupspreadsheet-writeexcel . If you39d care to donate to the Excel::Writer::XLSX project or sponsor a new feature, you can do so via PayPal: tinyurl7ayes . The following people contributed to the debugging, testing or enhancement of Excel::Writer::XLSX: Rob Messer of IntelliSurvey gave me the initial prompt to port Spreadsheet::WriteExcel to the XLSX format. IntelliSurvey (intellisurvey ) also sponsored large files optimisations and the charting feature. Bariatric Advantage (bariatricadvantage ) sponsored work on chart formatting. Eric Johnson provided the ability to use secondary axes with charts. Thanks to Foxtons (foxtons. co. uk ) for sponsoring this work. BuildFax (buildfax ) sponsored the Tables feature and the Chart point formatting feature. Because this software is licensed free of charge, there is no warranty for the software, to the extent permitted by applicable law. Except when otherwise stated in writing the copyright holders andor other parties provide the software 34as is34 without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the software is with you. Should the software prove defective, you assume the cost of all necessary servicing, repair, or correction. In no event unless required by applicable law or agreed to in writing will any copyright holder, or any other party who may modify andor redistribute the software as permitted by the above licence, be liable to you for damages, including any general, special, incidental, or consequential damages arising out of the use or inability to use the software (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the software to operate with any other software), even if such holder or other party has been advised of the possibility of such damages. John McNamara jmcnamaracpan. org
Przesunięcia w czasie rzeczywistym po godzinach Przedsprzedaż Wiadomości Flash Podsumowanie Podsumowanie Oferta Wykresy interaktywne Ustawienie domyślne Należy pamiętać, że po dokonaniu wyboru będzie ono dotyczyło wszystkich przyszłych wizyt na NASDAQ. Jeśli w dowolnym momencie jesteś zainteresowany przywróceniem ustawień domyślnych, wybierz ustawienie domyślne powyżej. Jeśli masz jakiekolwiek pytania lub masz jakiekolwiek problemy ze zmianą ustawień domyślnych, wyślij e-mail na adres isfeedbacknasdaq. Potwierdź swój wybór: Wybrałeś zmianę domyślnego ustawienia Wyszukiwania wyceny. Będzie to teraz domyślna strona docelowa, chyba że ponownie zmienisz konfigurację lub usuniesz pliki cookie. Czy na pewno chcesz zmienić swoje ustawienia Mamy przyjemność zapytać Proszę wyłączyć blokowanie reklam (lub zaktualizować ustawienia, aby zapewnić, że javascript i pliki cookie są włączone), abyśmy mogli nadal dostarczać Ci najwyższej jakości wiadomości na temat rynku i dane, których możesz oczekiwać...
Comments
Post a Comment