コード例 #1
0
        /// <summary>
        /// Finds and compares the number and outprints all the planet info if true
        /// </summary>
        /// <param name="find"></param>
        /// <param name="column"></param>
        private void WriteAllPlanetInfoIf(int compare, int column, bool greaterThan, bool lessThan, bool equalTo)
        {
            for (int j = 2; j <= 10; j++) // goes through each sheet
            {
                Excel excel = OpenFileAt(j);

                int planet = (int)excel.ReadCellDouble(1, 8);
                for (int i = 1; i <= planet; i++) // goes through the planet list
                {
                    double temp = excel.ReadCellDouble(planet, column);
                    if (temp < compare && lessThan)
                    {
                        WriteAllPlanetInfo(planet, excel);
                    }
                    else if (temp > compare && greaterThan)
                    {
                        WriteAllPlanetInfo(planet, excel);
                    }
                    else if (temp == compare && equalTo)
                    {
                        WriteAllPlanetInfo(planet, excel);
                    }
                }

                excel.Close();
            }
        }
コード例 #2
0
ファイル: Replacer.cs プロジェクト: roku674/StarportExcel
        public static string ReplacePlanetMethod(Excel excel, int sheet, int row, string newPlanetName)
        {
            if (excel.ReadCellString(row, 2).Equals("") || excel.ReadCellString(row, 2).Equals(null)) // if the box was empty
            {
                excel.WriteToCell(row, 2, newPlanetName);                                             //planet in box
                excel.WriteToCell(row, 1, row.ToString());                                            // update number next to it

                if (row > excel.ReadCellDouble(1, 8))                                                 //if the new numbeer is greater than the total
                {
                    excel.WriteToCell(1, 8, row.ToString());                                          //update number
                    return(newPlanetName + " added to" + " slot " + row + " on sheet " + sheet + " Totals updated to " + row);
                }
                else
                {
                    return(newPlanetName + " added to" + " slot " + row + " on sheet " + sheet);
                }
            }
            else if (excel.ReadCellString(row, 2).Equals(newPlanetName))
            {
                return(newPlanetName + " information updated ");
            }
            else
            {
                string oldPlanetName = excel.ReadCellString(row, 2);
                excel.WriteToCell(row, 2, newPlanetName); //put the planet in the box

                return(newPlanetName + " replaced " + oldPlanetName + " in slot " + row + " on" + " sheet " + sheet);
            }
        }
コード例 #3
0
        private void ParadisesButton_Click(object sender, EventArgs e)
        {
            int.TryParse(numberTextBox.Text, out int temp);

            if (temp > 0)
            {
                int planetNumber = Int32.Parse(numberTextBox.Text);
                Excel excel = OpenFileAt(8);
                string planet = excel.ReadCellString(planetNumber, 2); //read row planet number column c
                excel.Close();//dellocate
                numberTextBox.Text = planet;
                RetrievePicture("IGP", planetNumber);
            }
            else
            {
                Excel excel = OpenFileAt(8);
                int planet = (int)excel.ReadCellDouble(1, 8); //amount of planets

                output.WriteLine("Paradises: ");
                for (int i = 1; i <= planet; i++)
                {
                    WriteAllPlanetInfo(i, excel);
                }
                output.Flush();
                excel.Close();

                MessageBox.Show("Paradises added to " + outputPath, "Completed");
            }
        }
コード例 #4
0
 private void WriteAllPlanetInfo(int planetNum, Excel excel)
 {
     output.Write(excel.ReadCellString(planetNum, 2) + " | "); //column C
     //Console.WriteLine(excel.ReadCellString(planetNum, 2));
     for (int i = 10; i <= 38; i++)
     {
         //Console.WriteLine(i);
         if (i == 11 || i == 12 || (i >= 14 && i <= 19) || (i >= 25 && i <= 37))
         {
             var temp = excel.ReadCellDouble(planetNum, i);
             output.Write(temp + " | ");
         }
         else if (i == 38)
         {
             string temp = excel.ReadCellString(planetNum, i);
             output.Write(temp);
         }
         else
         {
             string temp = excel.ReadCellString(planetNum, i);
             output.Write(temp + " | ");
         }
     }
     output.WriteLine("");
 }
コード例 #5
0
        private void BuildListButton_Click(object sender, EventArgs e)
        {
            Excel excel = OpenFileAt(11);
            int planetsToBuild = (int)excel.ReadCellDouble(1, 15);

            for (int i = 1; i <= planetsToBuild; i++) //planet tally is in P column
            {
                //output.Write("Coordinates: ");
                output.Write(excel.ReadCellString(i, 2)); //coordinates
                output.Write(" | ");

                //output.Write("Planet Name: ");
                output.Write(excel.ReadCellString(i, 3)); //colony name
                output.Write(" | ");

                //output.Write("Colony Name: ");
                output.Write(excel.ReadCellString(i, 4));//Planet Name
                output.Write(" | ");

                output.Write("Zounds: ");
                output.Write(excel.ReadCellBool(i, 5));//Zoundsable
                output.Write(" | ");

                output.Write("Medium: ");
                output.Write(excel.ReadCellBool(i, 6));//Medium
                output.Write(" | ");

                output.Write("?: ");
                output.Write(excel.ReadCellBool(i, 7));//Questionable
                output.Write(" | ");

                output.Write("Decconstruct: ");
                output.Write(excel.ReadCellBool(i, 8));//Deconstruct
                output.Write(" | ");

                //output.Write("Research x/10: ");
                output.Write((int)excel.ReadCellDouble(i, 9)); //Research
                output.Write(" | ");
                output.WriteLine("");
            }
            output.Flush();
            MessageBox.Show("Build List added to output", "Message");
        }
コード例 #6
0
        /// <summary>
        /// Finds and outputs the planet info if the integer matches
        /// </summary>
        /// <param name="find"></param>
        /// <param name="column"></param>
        private void WriteAllPlanetInfoIf(int find, int column)
        {
            for (int j = 2; j <= 10; j++) // goes through each sheet
            {
                Excel excel = OpenFileAt(j);

                int planet = (int)excel.ReadCellDouble(1, 8);
                for (int i = 1; i <= planet; i++) // goes through the planet list
                {
                    int temp = (int)excel.ReadCellDouble(planet, column);
                    if (temp.Equals(find))
                    {
                        WriteAllPlanetInfo(planet, excel);
                    }
                }

                excel.Close();
            }
        }
コード例 #7
0
        private void LowMetalButton_Click(object sender, EventArgs e)
        {
            for (int j = 2; j <= 10; j++) // goes through each sheet
            {
                Excel excel = OpenFileAt(j);

                int planet = (int)excel.ReadCellDouble(1, 8);
                for (int i = 1; i <= planet; i++) // goes through the planet list
                {
                    if (excel.ReadCellInt(i, 26) <= 5000)
                    {
                    }
                }
            }
        }
コード例 #8
0
        public static void ClearBuildList(Excel excel)
        {
            int planets = (int)excel.ReadCellDouble(1, 15);

            //excel.WriteToCell(1, 15, "");
            for (int i = 1; i <= planets; i++)
            {
                excel.WriteToCell(i, 1, "");
                excel.WriteToCell(i, 2, "");
                excel.WriteToCell(i, 3, "");
                excel.WriteToCell(i, 4, "");
                excel.WriteToCell(i, 5, "");
                excel.WriteToCell(i, 6, "");
                excel.WriteToCell(i, 7, "");
                excel.WriteToCell(i, 8, "");
                excel.WriteToCell(i, 9, "");
                excel.WriteToCell(i, 10, "");
                excel.WriteToCell(i, 11, "");
            }
            Console.WriteLine("Build List Cleared");
        }
コード例 #9
0
ファイル: Replacer.cs プロジェクト: roku674/StarportExcel
        public static string ReplacePlanetMethod(int sheet, int row, string newPlanetName)
        {
            Excel excel = OpenFileAt(sheet);

            if (excel.ReadCellString(row, 2).Equals("") || excel.ReadCellString(row, 2).Equals(null)) // if the box was empty
            {
                excel.WriteToCell(row, 2, newPlanetName);                                             //planet in box
                excel.WriteToCell(row, 1, row.ToString());                                            // update number next to it

                if (row > excel.ReadCellDouble(1, 8))                                                 //if the new numbeer is greater than the total
                {
                    excel.WriteToCell(1, 8, row.ToString());                                          //update number

                    excel.Close();
                    return(newPlanetName + " added to" + " slot " + row + " on sheet " + sheet + " Totals updated to " + row);
                }
                else
                {
                    excel.Close();
                    return(newPlanetName + " added to" + " slot " + row + " on sheet " + sheet);
                }
            }
            else if (excel.ReadCellString(row, 2).Equals(newPlanetName))
            {
                excel.Close();
                return("Identitcal planet found! Nothing has been added");
            }
            else
            {
                string oldPlanetName = excel.ReadCellString(row, 2);
                excel.WriteToCell(row, 2, newPlanetName); //put the planet in the box

                excel.Close();
                return(newPlanetName + " replaced " + oldPlanetName + " in slot " + row + " on" + " sheet " + sheet);
            }
        }
コード例 #10
0
        private void SameSystemListButton_Click(object sender, EventArgs e)
        {
            Coordinates system = Algorithms.GetCoordinates(numberTextBox.Text);

            for (int j = 2; j <= 10; j++) // goes through each sheet
            {
                Excel excel = OpenFileAt(j);

                int planet = (int)excel.ReadCellDouble(1, 8);
                for (int i = 1; i <= planet; i++) // goes through the planet list
                {
                    string planetName = excel.ReadCellString(i, 2);
                    Coordinates planetCoords = Algorithms.GetCoordinates(planetName);
                    if (system.x == planetCoords.x && system.y == planetCoords.y)
                    {
                        output.WriteLine(planetName);
                    }
                }
                excel.Close();
            }

            output.Flush();
            MessageBox.Show("Colonies in the Same System to output", "Message");
        }
コード例 #11
0
        private void VolcanicsButton_Click(object sender, EventArgs e)
        {
            int.TryParse(numberTextBox.Text, out int temp);

            if (temp > 0)
            {
                int planetNumber = Int32.Parse(numberTextBox.Text);
                Excel excel = OpenFileAt(10);
                string planet = excel.ReadCellString(planetNumber, 2); //read row planet number column c
                excel.Close();//dellocate
                numberTextBox.Text = planet;
                RetrievePicture("Vol", planetNumber);
            }
            else if (VolcanicZoundsCheckBox.Checked && VolcanicsCheckBox.Checked) //both
            {
                Excel excel = OpenFileAt(10);
                int planet = (int)excel.ReadCellDouble(1, 8); //amount of planets

                output.WriteLine("Volcanics: ");

                for (int i = 1; i <= planet; i++)
                {
                    WriteAllPlanetInfo(i, excel);
                }
                output.Flush();
                excel.Close();
                MessageBox.Show("Volcanics added to " + outputPath, "Completed");
            }
            else if (VolcanicZoundsCheckBox.Checked && !VolcanicsCheckBox.Checked) //Volcanic Zounds only
            {
                Excel excel = OpenFileAt(10);
                int planet = (int)excel.ReadCellDouble(2, 8); //amount of zounds

                output.WriteLine("Volcanic Zounds: ");

                for (int i = 1; i <= planet; i++)
                {
                    output.WriteLine(excel.ReadCellString(i, 5)); //column F
                }
                output.Flush();
                excel.Close();
                MessageBox.Show("Volcanics Zounds added to " + outputPath, "Completed");
            }
            else if (!VolcanicZoundsCheckBox.Checked && VolcanicsCheckBox.Checked) //normies only
            {
                Excel excel = OpenFileAt(10);
                int planet = (int)excel.ReadCellDouble(1, 8); //amount of planets

                output.WriteLine("Volcanic Non-Zounds: ");

                for (int i = 1; i <= planet; i++)
                {
                    string box = excel.ReadCellString(i, 2);
                    for (int j = 0; j < box.Length; j++)//go through string
                    {
                        if (box[j].Equals('.'))
                        {
                            if (j + 5 < box.Length && !box[j + 5].Equals('Z'))
                            {
                                output.WriteLine(excel.ReadCellString(i, 2)); //column C
                            }
                            else if (j + 3 == box.Length - 1 && !box[j - 4].Equals('.'))
                            {
                                output.WriteLine(excel.ReadCellString(i, 2)); //column C
                            }
                        }
                    }
                }
                output.Flush();
                excel.Close();
                MessageBox.Show("Volcanics without Zounds added to " + outputPath, "Completed");
            }
            else
            {
                MessageBox.Show("Nothing was selected");
            }
        }